Skip to content

Commit

Permalink
Merge pull request #572 from griffinsorrentino/master
Browse files Browse the repository at this point in the history
Added support for deleting FCM token
  • Loading branch information
nbransby authored Jul 26, 2024
2 parents e175fc0 + 219bd60 commit d80a467
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions firebase-messaging/api/android/firebase-messaging.api
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
public final class dev/gitlive/firebase/messaging/FirebaseMessaging {
public fun <init> (Lcom/google/firebase/messaging/FirebaseMessaging;)V
public final fun deleteToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getAndroid ()Lcom/google/firebase/messaging/FirebaseMessaging;
public final fun getToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun subscribeToTopic (Ljava/lang/String;)V
Expand Down
1 change: 1 addition & 0 deletions firebase-messaging/api/jvm/firebase-messaging.api
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
public final class dev/gitlive/firebase/messaging/FirebaseMessaging {
public fun <init> ()V
public final fun deleteToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun subscribeToTopic (Ljava/lang/String;)V
public final fun unsubscribeFromTopic (Ljava/lang/String;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ public actual class FirebaseMessaging(public val android: com.google.firebase.me
}

public actual suspend fun getToken(): String = android.token.await()

public actual suspend fun deleteToken() {
android.deleteToken().await()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ public expect class FirebaseMessaging {
* @return [String] FCM token
*/
public suspend fun getToken(): String

/**
* Delete FCM token for client
*/
public suspend fun deleteToken()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public actual class FirebaseMessaging(public val ios: FIRMessaging) {
}

public actual suspend fun getToken(): String = awaitResult { ios.tokenWithCompletion(it) }

public actual suspend fun deleteToken() {
await { ios.deleteTokenWithCompletion(it) }
}
}

public suspend inline fun <T> T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public external fun getMessaging(

public external fun getToken(messaging: Messaging = definedExternally, options: dynamic = definedExternally): Promise<String>

public external fun deleteToken(messaging: Messaging = definedExternally): Promise<Boolean>

public external interface Messaging
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public actual class FirebaseMessaging(public val js: Messaging) {
}

public actual suspend fun getToken(): String = dev.gitlive.firebase.messaging.externals.getToken(js).await()

public actual suspend fun deleteToken() {
dev.gitlive.firebase.messaging.externals.deleteToken(js).await()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public actual class FirebaseMessaging {
public actual suspend fun getToken(): String {
TODO("Not yet implemented")
}

public actual suspend fun deleteToken() {
TODO("Not yet implemented")
}
}

0 comments on commit d80a467

Please sign in to comment.