EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

No background notifications on IOS // Version 5.0.2 #565

Closed Lacos247 closed 6 years ago

Lacos247 commented 6 years ago

Hi,

so far everything works fine but I don't get background notifications on ios. If I start the app - the notifications are delivered and shown with the local notifications plugin. Remote Notifications are activated in the apropriate Xcode Project (and "UIBackgroundModes" in Info.plist , too).

In main.ts (before bootstrap) I have the following code. My expectation is that the local notification is shown even if the app is in the background. What I am missing? Any help would be appreciated!!!

firebase.init({ // Optionally pass in properties for database, authentication and cloud messaging, // see their respective docs and 'iOSEmulatorFlush' to flush token before init. iOSEmulatorFlush: true, onPushTokenReceivedCallback: function(token) { console.log("Firebase push token: " + token); }, onMessageReceivedCallback: function(message) { console.log("scheduling test notification.."); LocalNotifications.schedule([{ id: 1, title: 'New Local Test Title', body: 'New Local Test message', ticker: 'The ticker', badge: 5, groupedMessages:["The first", "Second", "Keep going", "one more..", "OK Stop"], //android only groupSummary:"Summary of the grouped messages above", //android only ongoing: true, // makes the notification ongoing (Android only) smallIcon: 'res://heart', sound: "customsound-ios.wav", // falls back to the default sound on Android at: new Date(new Date().getTime() + (1 * 1000)) // 10 seconds from now }]).then( function() { console.log("Notification scheduled"); }, function(error) { console.log("scheduling error: " + error); } ); } }).then( (instance) => { console.log("firebase.init done"); }, (error) => { console.log("firebase.init error: " + error); } );

EddyVerbruggen commented 6 years ago

For anyone interested, this last issue was because the delegate wiring was disabled in this particular project. Never do this.

tangjh commented 6 years ago

Any hint? Still can't get it work. :( The code works on emulator and real phone when on foreground. Just doesn't work for background. https://github.com/tangjh/pushproject

EddyVerbruggen commented 6 years ago

@tangjh You literally have the lines in your project I mentioned not to use in my previous reply: https://github.com/tangjh/pushproject/blob/7bae13ec430e19c5c39b4dcc3cf4eb8c6e2a5e57/app/App_Resources/iOS/Info.plist#L52-L53

tangjh commented 6 years ago

Thank you so much Eddy! I misunderstood what you have written. After removing the key, I encounter authorisation issue for APNS. I've fixed that and now background push notification is working!