-
Notifications
You must be signed in to change notification settings - Fork 448
Notification message not shown when app is in the background #237
Comments
Been jiggling some more with it, but it seems that calling the firebase.init only succeeds when the app is installed and run for the first time. The onPushTokenReceivedCallback is called and then we can post notifications to it. But then I close the app (runs in background) and start it up again. The init function triggers the following line in the log: Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001. |
Okay, fail by me... Problem solved by adding 'priority': 'high' to the request... |
I am facing the same issue. The plugin is able to recognize the foreground push messages, but nothing happens when the application is in background. Tried changing the priority to high and still no luck. @ViVer-7 Can you suggest something? |
No, I'm sorry... setting the priority to high worked fine for me. |
Hi @sudhanshu-15 , did you solve if for iOS? I am able to the foreground but not the background (in Android it works). Below the curl command I am using: curl -X POST --header "Authorization: key=MY_KEY" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{"notification":{"title": "My title", "text": "My text", "sound": "default", "priority": "high", "badge":3}, "data":{"foo":"bar"}, "to": "REAL_IOS_DEVICE_TOKEN"}" Any suggestions? |
@simonettoa Did you also configure this (UIBackgroundModes)? |
@EddyVerbruggen yes, below part of the Info.plist
I receive the notification in foreground but nothing in background, then if I open the app I see the notification (I see an alert, it's what I've put) |
@simonettoa I am still stuck on this problem. Android works perfectly well but on iOS I can get the message in foreground but when the goes into background nothing happens. No clue how to fix this, I was hoping @EddyVerbruggen could help. |
@sudhanshu-15 I'm looking at this later today with the demo app. |
Confirmed it works correctly in the demo app, but: .. please make sure you've enabled Push notifications in Xcode as mentioned in the readme (I just made it stand out more here. Otherwise you'll only see foreground pushes. This iOS push thing is HARD for all of us, so please be patient while configuring and testing it. |
@EddyVerbruggen thanks, I will try and let you know asap! |
@EddyVerbruggen thanks for looking into this. I am pretty confident that I enabled Push notifications on xcode. Sorry but it is very early morning here so will check in sometime and let you know. |
@sudhanshu-15 you may have removed and re-added the platforms/ios folder in the meanwhile. That would reset it. |
@EddyVerbruggen I am still not getting anything when the app is in background. I have enable the push notifications on Xcode. This is what I am seeing in my logs: NativeScript loaded bundle file:///System/Library/Frameworks/UserNotifications.framework |
That "Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001" is the problem, as long as you have that you won't see notifications in the background. It's a pretty popular searchterm on Google. Did you add you APNS certs to the developer console as well? |
@EddyVerbruggen I have my provisioning profile setup correctly. I also added APNS certs to developer console. I tried looking at possible solutions to "Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001" but couldn't find anything substantial. |
So... Will you share your platforms/ios folder with me so I can take a look? |
Can I mail it to you? |
That's ok, my email is on my github profile. Make sure to just zip your platforms/ios folder, I need the entire Xcode project. |
Done, shared it with you. You might have got a notification. It is on Google Drive. |
Got it, thx |
You'll need to fix that first. |
I keep trying to fix it but every time I run tns run ios it reappears again. |
You created a You can take this offline to email if you like (gets spammy!) - we'll post the result here. |
Sure |
hi, actually I'd be grateful if you'd keep debugging here if you don't mind. I'm having a TRULY HORRIBLE time getting anything working on iOS. I have worked with other push services before (Pushbots, Urban Airship, Parse, etc) and it's never been this hard. Crazy! What my experience is is that I can't get a push notification to work at all, foreground or in the background, on iOS, but I do get an alert that tells me what gets sent through the console. I'll keep tinkering. |
@jlooper here is the update so far, I tried removing the hook script as @EddyVerbruggen suggested but still the app is not able to receive notifications in background. I am still getting the <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1 |
@EddyVerbruggen I'm having the same behavior of @sudhanshu-15 `Successfully run application org.nativescript.firebaseTest on device with ID 4e4aeec59464a57d30ede11b8c1a14ede6fff1ae. 2017-01-19 12:38:50.640 firebaseTest[315] [Firebase/Core][I-COR000001] Configuring the default app. 2017-01-19 12:38:50.657 firebaseTest[315:] <FIRAnalytics/INFO> Firebase Analytics v.3600000 started 2017-01-19 12:38:50.657 firebaseTest[315:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/Y0Yjwu) 2017-01-19 12:38:50.660 firebaseTest[315] [Firebase/Crash][I-CRA000004] Successfully enabled 2017-01-19 12:38:50.669: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO 2017-01-19 12:38:50.670: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" 2017-01-19 12:38:50.674: <FIRMessaging/INFO> FIRMessaging library version 1.2.0 2017-01-19 12:38:50.707: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO 2017-01-19 12:38:50.737 firebaseTest[315] [Firebase/Core][I-COR000018] Already sending 2017-01-19 12:38:51.033 firebaseTest[315] [Firebase/Core][I-COR000018] Already sending logs. 2017-01-19 12:38:51.127 firebaseTest[315] [Firebase/Core][I-COR000019] Clearcut post completed. 2017-01-19 12:38:51.204 firebaseTest[315] [Firebase/Core][I-COR000019] Clearcut post completed. 2017-01-19 12:38:51.262 firebaseTest[315] [Firebase/Core][I-COR000019] Clearcut post completed. 2017-01-19 12:38:51.346 firebaseTest[315:] <FIRAnalytics/INFO> Firebase Analytics enabled CONSOLE LOG file:///app/tns_modules/nativescript-plugin-firebase/firebase.js:244:20: User granted push notifications? true CONSOLE LOG file:///app/main-view-model.ts:49:28: token from google cGNtdJ0uxAM:APA91bHp3sKfrv92B69RzN0e25pVnvt2K2PyGm9gTVsQd7Df3DENhngNRc_uf6VxdVg3ldWS1vdiHavolHLzImwWrRMXpkki1WdwrVj-O30L8bnHsuqDF6aocNphoqORFVtRwRrudA2_ I've put the registration token event in a button, so after the load of the app. I've tried to launch the app trough Xcode but I have the same messsage of sudhanshu-15 about --> 'clang: error: linker command failed with exit code 1 (use -v to see invocation)' |
@simonettoa You can remove the Hook script from the project folder if your entitlements file is getting changed every time you run |
...and to pile on to poor @EddyVerbruggen my logs are the same: (what's all that about APNS token Error and swizzling?) 2017-01-19 13:09:55.229: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO |
Guess we all are facing the same issue. As per my conversation with @EddyVerbruggen the root cause of not getting a true push is: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" Google search of this issue didn't yield any fruitful result. Let's hope we can find a solution soon. |
@jlooper Can you send me your project so I can zoom in on your issue as well? |
@jlooper AFAIK it boils down to the file /platforms/ios/yourappname/Resources/yourappname.entitlements - that should look like this:
The important bit being: <key>aps-environment</key>
<string>development</string> I can confirm the full project @sudhanshu-15 gave me lacks it and like I said I will investigate ways to add it. Once I have new info I will of course add it here. |
Mine looks correct, as per the model above. There may be more info on this thread: firebase/quickstart-ios#111 |
@EddyVerbruggen even after removing the entitlement hook script, the entitlements file is being overwritten every time I
But it gets overwritten every time. |
@samuelagm Yeah I rechecked the hook script and it actually looks for an existing script and doesn't touch it if it exists already. I just returned from my dayjob and pushed code to a few other plugins, not I'm diving back into this issue. Oh but first I need to put the kids to bed so don't hold your breath. @jlooper Sounds like you should be ok from the plugin side. I'd love to check your firebase console and certificates at this point. |
@EddyVerbruggen thanks a lot for helping out. I am available whenever you are ready to look into this again. |
@EddyVerbruggen btw thanks a lot for the help |
Please update to 3.9.2 and take note of the update messaging instructions, let me know if issues remain afterwards. |
@EddyVerbruggen it works like a charm!! Thanks a lot!! Now getting push notifications even when the app is in background. |
That's quick, thanks for letting me know :) |
Hi there, it's still not working for me. What i've done:
then the logs are similar than the old one with the same APNS failed error
I came from Xamarin, so to check if it's a certificate issue, I've created a small project and checked the notifications. I don't know what else to do, if you want @EddyVerbruggen I can send you my project, maybe there's something I haven't done correctly. |
Btw I was able to launch the app also through Xcode, but still same message error/warning and same result, foreground works, background not. And this is a *.ts simple project made just to test firebase notifications. |
@simonettoa can you send the entire project? |
@EddyVerbruggen I just shared a folder in dropbox with the entire project, thanks! I used your email address from github. |
@simonettoa You're doing everything right, except you need to remove |
@EddyVerbruggen it works...that was the error; THANKS A LOT!!! Still in the log I can see the same 'warning'. Just for the record.
|
Hi, I have a problem using this plugin, could use some help here...
I'm using curl to post a notification message to Firebase, like so:
Headers:
JSON:
Using the app sample code downloaded from Firebase, this works... So I know that my Firebase key and my authorization key are correct (and also my Apple certificate). When the app is in the background, I receive a sound and a notification in the notification centre on iOS.
Now I'm trying to use my own sample code, with the following result:
When the app is in the foreground, an event is triggered and I receive the data, so that works perfectly!
Now when the app is in the background, I would expect that (as in the sample above), iOS will play a sound, show a badge and display a notification in the notification centre....but it does not! Nothing happens...
Is something wrong with the plugin? Can anybody point me in the right direction?
Source code (main.ts) below:
The text was updated successfully, but these errors were encountered: