Development issue/problem:

With the new FirebaseMessaging service, you can easily unsubscribe and subscribe to :

FirebaseMessaging.getInstance().subscribeToTopic() ;
FirebaseMessaging.getInstance().unsubscribeFromTopic() ;

But is there any way to get all the themes that the current installation subscribes to?

How can I solve this problem?

Solution 1:

I searched PI’s, asked questions of SO’s, but I couldn’t find anything. There is nothing in PI that allows you to get all the subjects for a given token.

However, you can also do this via a GETrequest.

HTTP request to receive

https://iid.googleapis.com/iid/info/?details=true
Content type: application/json
Authorization: key=AAAAA….i1nM:APA9….. 81gTPXCE55….JLPEG0wZobG_ile8lI35JTzHYE5MC..BmDD_Cxj5OxB1Yh….Rs5lo3UwLNL9h-WcocGV….b5bYWNI55kzNsrHK-7GljUDtMn.

TOKEN in url : FirebaseInstanceId.getInstance().getToken(senderId, scope) ;

is in the Firebase console: Your project -> Settings -> Cloud messages -> Server key

Pay attention: Be careful when looking for the key, do not use the web api key, it is different.

You can find the SenderID under Settings -> Messages in the cloud -> SenderID

As a general rule, the scope of the TCM

Solution 2:

For those who want to test it with the CURL command line, follow the syntax I used :

#curl –location –GET query ‘https://iid.googleapis.com/iid/info/yourFCMDeviceToken?details=true’
–head ‘Authorization : Carrier of your_CloudMessaging_ServerKey” project.

Answer:

applicationVersion : ‘4194309’,
application : ‘com.domain.app’,
scope : ‘*’,
authorizedEntity : ‘913674269572’,
rel : { topics : { themeName : { addDate : ‘2020-08-19’ } } },
appSigner : ae7cbSomeHash23jsdfff34ac7ffd, platform
: ANDROID
}

Solution 3:

This issue is still ongoing, there is no API for it in the iOS SDK yet.

If your goal is to prevent a user from subscribing to the same thread multiple times and thus being notified multiple times of, say, a single comment in a group, then my solution would be a simple local cache with UserDefaults.

Pretty simple:

func subscribeTo(topic: String){
// First check that the user is not already subscribed to
// or not receiving multiple notifications
let localFlag = UserDefaults.standard.bool(forKey: topic)
if localFlag == true {
print(user already subscribed to topic) :(topic)
return
}
print(user tried to subscribe to topic :(topic))
// inform user is trying to subscribe CometChat user via Firebase to topic
Messaging.messaging().subscribe(toTopic : topic) { error in
if error == null {
print(subscribe CometChat user to topic) :(topic))
// set local flag as already subscribed
UserDefaults.standard.setValue(true, forKey : subject)
return
} In
, print failed (CometChat user tries to subscribe to (subject) : (error ?.localizedDescription ?????? (error unspecified))
}
}

My application’s thread registers the user and automatically gets a list of threads associated with the user, and automatically subscribes to the thread each time it runs.

The reason for this is the high level of security the user has when receiving the notification.

Flux :
User launches app-> topics extract-> iterate and go through topic for subscription function -> block if topic == true-> go through if topic != true

And then, of course, we assign a zero to the local pool in the subject after disconnection.

Unsubscribes are always successful without this kind of blocking, because the UX is preferably more conservative when the user doesn’t want to receive notifications.

Thank you!

Solution 4:

I never tried to program it.

But you can do it with goto firebase console->your project->cloud message->new notification->target->click on the topic tab next to the custom segment; just click on the message topic text box and you’ll get a list of subscribed topics.

Enter a description of the image here

Good luck!

 firebase subscribe to multiple topicsfirebase subscribe to topic iosreact-native firebase subscribe to topicfirebase subscribe to topic phpmessagingtopicmanagementresponseflutter firebase subscribe to topicfcm send to all devicesdevice to device messaging using fcmsend message to topic firebasefirebase api to subscribe to topicfirebase register token to topicmessaging/token-unsubscribe-failedfirebase consolefirebase cloud functions subscribe to topicsend push notification through rest apirest api to send push notificationsnotification rest apiinvalidregistrationhttps //fcm.googleapis.com/fcm/send examplepush notification in android using web apigcloud pubsub subscriptions creategoogle pubsub view messagesgoogle pubsub multiple subscribersgoogle pubsub delete messagegcloud pubsub topics publishgoogle pub/sub example

You May Also Like

Windows 10: No Internet Connection After Connecting to VPN Server

When connecting to the corporate VPN server (AlwaysOnVPN, Windows Server RRAS, or…