ostownsville / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
21 stars 17 forks source link

Updated readme and slight fix for topics #7

Closed chrisjpalmer closed 7 years ago

chrisjpalmer commented 7 years ago

Updated the readme. We should consider taking down the 'donate' stuff. Or if we can get back in touch with the original project manager we could leave it up for them.

Topics Slight fix for topics, you no longer need the '/topics/' prefix according to the current API.

Auto-subscription to Topics Also in a different PR it was discussed whether we needed to reimplement the automatic topic subscription to 'ios' and 'all' topics. The basis of this thought was to try and be consistent with the android side of the plugin. Android does indeed to some automatic topic subscription:

FirebaseMessaging.getInstance().subscribeToTopic("android");
 FirebaseMessaging.getInstance().subscribeToTopic("all");

And ios is meant to do the same (not actually a requirement of Firebase)

[[FIRMessaging messaging] subscribeToTopic:@"ios"]
[[FIRMessaging messaging] subscribeToTopic:@"all"]

However it turns out this is slightly tricker than we all thought. If you do it in the plugin initialiser, FCM returns an error saying that there is no device token. The reason is FCM hasn't been given a chance to load. You get this error specifically: Cannot subscribe to topic: ios with token: (null)

I had a brief look at this blog post and tried the suggested solution but it does not work - i am guessing due to FCM method swizzling which denies the callback from being fired directly.

We could turn swizzling off... it may solve the problem, or it may not. Nevertheless its a bit of work and debugging to do that. For now its probably okay to leave them out and perhaps take the auto-subscriptions out of the android side as well to be consistent.

The readme does not mention this 'auto-subscription' anywhere and it kind of goes against the expected behaviour of the plugin. Would be interested on your thoughts @ostownsville

Enabled [FIRMessaging messaging].delegate = self for iOS 9.0 I noticed that this code was only included in the iOS 10 preprocessor macro. Its actually needed for iOS 9 as well because even though data messages in iOS 9 don't use the message:didRecieveMessage: methods, the token refresh mechanism is actually provided though the FIRMessagingDelegate!

chrisjpalmer commented 7 years ago

Hi could we get this merged? This has an important fix for iOS 9.0

chrisjpalmer commented 7 years ago

Hi there. This one has a good fix for iOS 9, could we get merged?