EddyVerbruggen / nativescript-plugin-firebase

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

registerForPushNotifications issues with Custom Delegate endBackgroundTask #1602

Closed MohammedBashiru closed 4 years ago

MohammedBashiru commented 4 years ago

await messaging.registerForPushNotifications({ ...options })

calling the above method does not resolve if you approve or reject push notification permission.

I found the issue to be my custom delegate overriding whatever callback function the plugin is expected to call.

this method in my custom delegate is the problem. If I comment it out, the plugin resolves.

myApp.prototype.endBackgroundTask = function () { if (this.timer) { this.timer.invalidate(); this.timer = null; } this.timerCounter = 10; UIApplication.sharedApplication.endBackgroundTask(this.bgTask); this.bgTask = UIBackgroundTaskInvalid; console.log("End of background task."); };

@EddyVerbruggen Please any work around for this ? as I need my custom delegate for a background task.

EddyVerbruggen commented 4 years ago

I have no idea.. the plugin doesn't use endBackgroundTask and I don't see you using or overriding the appdelegate in that snippet..

MohammedBashiru commented 4 years ago

Yes. I taught as well. but removing this function resolves

registerForPushNotifications

without removing it. As soon as I accept or declines push permission. I see the log printed in terminal

console.log("End of background task.");

MohammedBashiru commented 4 years ago

the delegate am using is

https://github.com/NativeScript/sample-ios-background-execution/blob/master/app/custom-app-delegate.ts

MohammedBashiru commented 4 years ago

@EddyVerbruggen Please does the plugin fails to resolve when your app uses custom delegate? On further investigation it turns out that once I enable custom delegate the plugin fails to resolve

registerForPushNotifications

EddyVerbruggen commented 4 years ago

If you simply override the app delegate with your own then yeah, registering for pushes fails.

MohammedBashiru commented 4 years ago

Ok is there a work around for this ? Because am registering a custom delegate to use create background task.

EddyVerbruggen commented 4 years ago

Try and make them work together. One way may be to look at this dependency: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/6142ec1956165d08c2ef3d3995f58c5846a1bef4/src/package.json#L138