Nativescript-plugin-firebase: iOS : notifications works only after installing app

Created on 27 Apr 2017  ·  12Comments  ·  Source: EddyVerbruggen/nativescript-plugin-firebase

On iOS, I can make work the notifications (cloud messaging) only after the app installation
Also it only works for foreground notifications (background notifs are all received at resuming app)

But if I kill the app, or if the app close by itself (after long pausing), or after the next tns run ios, then the notifications stop to work at all :

  • onMessageReceivedCallback (inside init option) is ever no more called
  • firebase.addOnMessageReceivedCallback no more called too
    Until the next installation...

I use firebase console to send notifications, and whether I use single device (FCM) or user segment as target, the result is the same : it works only after the app installation

Here is version I use :

  • iPhone 6 (version 10.2 (14C92)
  • nativescript plugin firebase : 3.11.4
  • tns info :

    • angular : 2.4.3

    • nativescript : 2.5.4 │ Up to date

    • tns-core-modules : 2.5.2 │ Up to date

    • tns-android : 2.5.0 │ Up to date

    • tns-ios : 2.5.0 │ Up to date

On android, it works great

Most helpful comment

Had this same issue for several days on iOS. (Tested on both iOS 9 and iOS 10), {N} 3

Running firebase.init before the application has launched seems to be the cause of the issue. This can be remedied by running firebase.init in your first view-model.

Hope this helps.

All 12 comments

Same issue here. On Android everything works and on ios only after first app start.
Tested on IOS 8.4 & 10.1.1

I haven't made any changes to my certs yet I seem to have lost by background PNSs since upgrading to {N} 3.0.

Unlike @GrEg00z, my foreground notifs work regardless of killing, suspending app etc. and then resuming. Background does not work at all. This is on iOS.

UPDATE: Observing more carefully I see this is the same issue I am having. #367

I'm having similar issues on iOS. Foreground notifications work after installing and starting for the first time but not after killing and reopening app.

When the app is in the background onMessageReceivedCallback is not called at all for me. If the app was sent to the background during its first run but without killing, onMessageReceivedCallback is called when the app returns to the foreground.

Everything is working on Android though. I'm also on {N} 3.0

Not sure if this is any use but here's some log

2017-05-12 17:38:22.063: FIRMessaging library version 1.2.2
2017-05-12 17:38:22.129896+0100 appgitnotifications[972:201174] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-05-12 17:38:22.130 appgitnotifications[972] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-05-12 17:38:22.130124+0100 appgitnotifications[972:201174] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-05-12 17:38:22.130 appgitnotifications[972] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-05-12 17:38:22.156350+0100 appgitnotifications[972:201046] * -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
2017-05-12 17:38:22.157: FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-05-12 17:38:23.015830+0100 appgitnotifications[972:201200] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-05-12 17:38:23.018646+0100 appgitnotifications[972:201200] [MC] Reading from public effective user settings.
2017-05-12 17:38:24.119335+0100 appgitnotifications[972:201200] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
2017-05-12 17:38:24.119 appgitnotifications[972] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
2017-05-12 17:38:26.634047+0100 appgitnotifications[972:201046] [Common] _BSMachError: port a303; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2017-05-12 17:38:26.637649+0100 appgitnotifications[972:201046] [Common] _BSMachError: port a303; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2017-05-12 17:38:26.994647+0100 appgitnotifications[972:201046] CONSOLE LOG file:///app/index.js:23:20: Token Received: c6vrBe8YvS8:APA91bF6Aex0MvI-**
-SAj6MZ

CONSOLE LOG file:///app/index.js:23:20: Token Received: c6vrBe8YvS8:APA91bF6Aex0MvI-*-SAj6MZ
2017-05-12 17:39:55.556066+0100 appgitnotifications[972:201046] CONSOLE LOG file:///app/index.js:27:20: Push message received

CONSOLE LOG file:///app/index.js:27:20: Push message received
2017-05-12 17:40:05.235638+0100 appgitnotifications[972:201046] Cannot snapshot view (>) with afterScreenUpdates:NO, because the view is not in a window. Use afterScreenUpdates:YES.

*KILLED APP & RESTARTED****

017-05-12 17:41:28.395: FIRMessaging library version 1.2.2
2017-05-12 17:41:28.404893+0100 appgitnotifications[978:202430] * -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
2017-05-12 17:41:28.405: FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-05-12 17:41:28.424851+0100 appgitnotifications[978:202503] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-05-12 17:41:28.425 appgitnotifications[978] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-05-12 17:41:28.425674+0100 appgitnotifications[978:202503] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-05-12 17:41:28.426 appgitnotifications[978] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-05-12 17:41:28.465856+0100 appgitnotifications[978:202504] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
2017-05-12 17:41:28.466 appgitnotifications[978] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
2017-05-12 17:41:32.526989+0100 appgitnotifications[978:202503] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-05-12 17:41:32.528849+0100 appgitnotifications[978:202503] [MC] Reading from public effective user settings.

Has anyone had any success with iOS 10 notifications when the app is in the background?

I've managed to alter the code so I can now see the contents of my message coming through to the console when the app is in the background but cannot for the life of me get it to show as an iOS notification..

It's rather annoying... :(

@hackmushroom Care to share your code alterations? I've not been able to get any sign of life from push on iOS 10 (save first launch) since {N} 3

@vswee My mistake, I disabled the FIRMessaging disconnect but this is not the correct way to do it. I'm still trying but with zero success so far

Had this same issue for several days on iOS. (Tested on both iOS 9 and iOS 10), {N} 3

Running firebase.init before the application has launched seems to be the cause of the issue. This can be remedied by running firebase.init in your first view-model.

Hope this helps.

@rgchua Simple as that.
I can confirm that your recommendation restores both foreground and background push notifications on {N} 3 + iOS 10.
Brilliant job.

I can confirm that @rgchua is correct! Thank you, you legend! 👍

@rgchua : you save my life !!! It rocks now on iOS

Great finding 👍

Fix does not work on nativescript-plugin-firebase 4.0.2

These tips should be documented, particularly this: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/359#issuecomment-303953577

Was this page helpful?
0 / 5 - 0 ratings