Hi, I'm using your lib to get notification, I'm getting them by using Firebase but I have problem
sometimes - randomly I have problem with registration of device on brand new installation (for example by removing app and reinstall it again) on devices
I did get
Sending `FCMTokenRefreshed` with no listeners registered.
In my xcode logs and I can't get notification
I did put
this.refreshTokenListener = FCM.on(FCMEvent.RefreshToken, (token) => {
console.log('token received', token);
Alert.alert('Alert', token);
});
inside index.ios.js before AppRegistry.registerComponent('MyApp', () => app);
but when this error comes I was not able to get notifications
my Podfile:
platform :ios, '9.0'
target 'App' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for App
pod 'Firebase/Messaging'
pod 'GoogleMaps'
inherit! :search_paths
end
I did check 9.5.0, 9.4.0 and 9.3.0 and it occurs randomly on all versions
using react-native 0.46.4
I have
[FIRApp configure];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
Inside AddDelegate inside - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions before return YES
full logs from xcode:
2017-09-26 17:16:03.579 [info][tid:main][RCTCxxBridge.mm:186] Initializing <RCTCxxBridge: 0x16e2a660> (parent: <RCTBridge: 0x16e45390>, executor: (null))
2017-09-26 17:16:03.667 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-09-26 17:16:03.754 [info][tid:main][RCTRootView.m:302] Running application App ({
initialProps = {
};
rootTag = 1;
})
2017-09-26 17:16:06.461 [warn][tid:com.facebook.react.JavaScript] Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. (https://fb.me/migrating-from-react-proptypes)
2017-09-26 17:16:06.833 [warn][tid:com.facebook.react.JavaScript] Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement. (https://fb.me/migrating-from-react-create-class)
2017-09-26 17:16:07.488 [warn][tid:main][RCTEventEmitter.m:54] Sending `FCMTokenRefreshed` with no listeners registered.
2017-09-26 17:16:07.690 [warn][tid:com.facebook.react.JavaScript] Warning: Invalid argument supplied to oneOfType, expected an instance of array.
2017-09-26 17:16:07.736 [warn][tid:com.facebook.react.JavaScript] Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.
2017-09-26 17:16:07.795 [info][tid:com.facebook.react.JavaScript] register listener
2017-09-26 17:16:07.806 [info][tid:com.facebook.react.JavaScript] Running application "App" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
It might be the refresh token is broadcasted before JS gets initialized?
Does FCM.getFCMToken() give you refreshed token?
yup, I get token, however using this token does not get me notifiaction on device and I don't get error on Firebase console when trying to use this deviceToken for sending notification
if you sent a notification to all devices in console, can the device receive it? want to confirm it gets registered with firebase correctly.
then I send to all devices I don't get notifications on this device with 'broken' token
all others device get this global notification
sounds like the device isn't registered to firebase correctly. is swizzling working fine? you should see the swizzling log in xcode console. Have you granted right permission for notification?
I did request permisions in component that I render:
async componentDidMount() {
await FCM.requestPermissions();
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
this.handleNotification(notif);
});
FCM.getInitialNotification().then((notif) => {
if (Platform.OS === 'ios' && _.isObject(notif)) {
notif.opened_from_tray = true;
}
this.handleNotification(notif);
});
}
I don't have any changes in Info.plist related with Firebase, however I don't get log about this "proxy" parametr
it turns out that in development mode - then we check for bundle to complete problem occurs offten
Now, I checking release version off app.
I did event try to use FCM.deleteInstanceId() but then I'm not getting new token (getToken method return old token that does not works anymore), is there is a method to reintialize Firebase?
@tobob reinstall the app
I did this about 75 times today ;)
I know that after FCM.deleteInstanceId() I need to reinstall app, but this is not solution ;)
You will need to get a new firebase id and associate with APNS token after deleting the old one. It was done by swizzling and the repo doesn't bridge a method to get a new one. In short, don't use FCM.deleteInstanceId()
back to your original question, which is the refresh token getting called early. can you log it here https://github.com/evollu/react-native-fcm/blob/master/ios/RNFIRMessaging.m#L256 see what refresh token is?
I put breakpoint there, I get same token that I get by using getToken methods
but then I use this token I don't get notifications, however I don't get errors while sending to this token
also I get notification about Sending 'FCMNotificationReceived' with no listeners registered. in react-native debugger
that's interesting, that mean you get the notification but it is not hook with JS listner
no, I don't get them either on Objective C site, I did put debug inside line 314 and nothing happened when I send notification through Firebase
edit.. wait, it can be a clue
sorry, I probably open new app from notifiaction
but I see them then I open device logs
<APSCourier: 0x14580430>: Stream processing: complete yes, invalid no, length parsed 281, parameters {
APSProtocolBaseToken = < 1367334e bf8be6e0 1367334e bf8be6e0 1367334e bf8be6e0 1367334e bf8be6e0 >;
APSProtocolCommand = 10;
APSProtocolMessageID = <a0d5a8c7>;
APSProtocolMessagePriority = 10;
APSProtocolMessageTimestamp = 1506525837971476502;
APSProtocolPayload = <7b226763 6d2e6e2e 65223a22 31222c22 676f6f67 6c652e63 2e612e74 73223a22 31353036 35323538 3338222c 22617073 223a7b22 616c6572 74223a22 447a6977 6b61206d 61c58261 227d2c22 676f6f67 6c652e63 2e612e75 6474223a 2230222c 22676f6f 676c652e 632e612e 65223a22 31222c22 676f6f67 6c652e63 2e612e63 5f696422 3a223232 38373636 32363036 34363334 38363535 34222c22 67636d2e 6d657373 6167655f 6964223a 22303a31 35303635 32353833 37393337 37363925 36333935 63373932 36333935 63373932 227d>;
incoming message is for proxy slave that is *not* connected.
sorry I have no clue what those means or how to fix them.
still Sending 'FCMNotificationReceived' with no listeners registered. is more concerning. can you capture [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; in AppDelegate.m?
but this is an info when I try to send to all devices, then I try to send to particular I get nothing
let's fix the global notification first. Looks like it is different from your original issue.
I put brakpoint on [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; and I did send global message to iOS devices, I get nothing, to check if breakpoint is working I did click into LocalNotification - and Xcode stops on this line, so I didn't get this remove notifications
so weird. your device is iOS10?
Yes, iPhone 5 with iOS10, I did test it agains iphone6plus and iphoneSE
I will check logs of device on app startup
you are using xcode 8 or 9? need to do a fix for 9 in appDelegate.m
also try to reproduce with quickstart-ios by firebase team. see if their native example works
Xcode 9, I did update 3 days ago
I did check it on quickstart-ios, it works smooth :P 馃
what I think - this could be an issue with checking Bundling 'index.ios.js' to compleate
I did downgrade FirebaseInstanceID into 2.0.0 and I think it works better, I will let you know tommorow, I will check it agains other devices
there is a change need to be made in AppDelegate.m if you are using xcode 9 otherwise you should get a warning, did you fix it?
you mentioning about: https://stackoverflow.com/questions/41477241/react-native-xcode-upgrade-and-now-rctconvert-h-not-found ?
I will let you know :)
BTW thanks for support, you are the best ;)
no I mean this guy
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
the type of completionHandler is changed
I did update this type but I don't see any changes, but maybe it will help in future, however downgrade to FirebaseDeviceId resolve my problems, even if I get Sending 'FCMTokenRefreshed' with no listeners registered. when app is loading Im still able to get notifications on device
problem also occurs mostly in debugging env, when app is waiting for index.ios.js
solution for me:
pod 'FirebaseInstanceID', "2.0.0"
@tobob can you explain what pod 'FirebaseInstanceID', "2.0.0" does? What is the default version coming with Messaging?
in spec I see that there is ~> 2.0
locking yourself in 2.0.0 may cause other problems. fire a bug to firebase?
Yesterday when I was looking around I found
https://stackoverflow.com/questions/46391818/fcm-push-notifications-do-not-work-on-ios-11
I tired it, it works for me, however it was not my issue
@evollu I think that you can fire bug to firebase when more users will come with same problem and source of problem will be more known
Thanks for your link. looks like Firebase has already fixed the bug in coming release. For now we should lock version to 2.0.0 as you did
I still get a Sending 'FCMTokenRefreshed' with no listeners registered. warning with a fresh install, even with FirebaseInstanceID 2.0.4, and even though I have FCM.on(FCMEvent.RefreshToken, (token) => {...}) directly in an included file (thus executing immediately)
@antoinerousseau it is possible that you get Sending 'FCMTokenRefreshed' with no listeners registered. because native sdk still runs before JS boots up.
You should get new token from getFCMToken
Yes it's working but that warning shouldn't show up
@antoinerousseau any PR that fixes this is welcomed. My idea is to move [FIRApp configure] into module init. but it could cause compatibility issue with other firebase rn modules
@evollu I tried but I couldn't find this warning in the source code (and I only know about JS dev)
can't do anything with iOS now
Hey! Any updates with Sending 'FCMTokenRefreshed' with no listeners registered warning?
@suhabaobaid it might happen when you start the app because the token refreshed before react is ready. but when you call getFCMToken again in javascript it should return the new token
@evollu so what you're saying is that we shouldn't worry about that warning ?
@EduardJS yes. as long as you only see the warning on launch