-
-
Notifications
You must be signed in to change notification settings - Fork 50
[iOS] Callback onMessage
is never called on Firebase Messaging for iOS
#24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm having exacly the same issue, i can receive push when background, but not when foreground throght onMessage method.. searching the plugins code, i see that a need to set showNotificationsWhenInForeground to true.. but not working anyway... I'm using iOS 14 and 15 |
@triniwiz I also ran into this issue and did some more testing to try to figure out the root cause of the problem. Here are a few of my findings.
Further investigation, I found that only 3 methods from the Firebase Messaging plugin's AppDelegate is being called:
None of the methods from I used the latest version that was released today ( Hope that helps :) |
Just a quick uninformed thought, though it may be completely off the mark. Firebase relies on a lot of swizzling of the AppDelegate; does NativeScript do anything odd with its own handling of AppDelegate that might cause the swizzling to fail? |
I think might be a matter of when |
@triniwiz It turns out to be the initialization issue. In an Angular project, initializing it in the // main.ts
import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-messaging';
const firebaseInit = firebase().initializeApp();
if (firebaseInit) {
firebase().messaging();
} |
What about apps that need messaging only after user authentication? |
Please update to the latest version |
@triniwiz I have a similar problem on iOS, even after installing the latest firebase-messaging plugin (1.0.0-alpha.41). When testing the push notifications in Simulator using an apns file like this:
(which is descriobed here https://betterprogramming.pub/how-to-send-push-notifications-to-the-ios-simulator-2988092ba931), then I see the notification in Simulator in all app states (foreground, background and closed). When testing the push notifications on a real iOS device with our real server or sending a message via Firebase Console directly to the device, I do not even see a notification (no matter which state the app has) and no callback is called. On Android the new firebase messaging plugin seems to work as expected. |
@felixkrautschuk I didn't know about the sim notifications , I can see this being an issue since there are some checks in the code that may cause issues with the sim as for the issue with the real device does the app use any custom delegates by chance ? |
Another thing please try calling |
@triniwiz thanks for your reply. I uncommented the custom delegate. And I moved the firebase().initializeApp(); to the beginning of app.js but unfortunately this does not help. |
Do you have a sample app of how your app is setup ? The best I can do w/o an app is point you to the demo app in this project |
@triniwiz I believe it works now on my side, even with our custom app delegate and with initializing Firebase in the app launch event. The only change: I added the following line after initializing firebase:
I did not find this method in the docs but my IDE suggested this method from the plugins API ;) |
You should call that register after requesting permission |
Even though I receive notifications when app is in background,
onMessage
callback is never triggered, neither on foreground nor on background.This works on android but not on iOS. I use iOS 15.
The text was updated successfully, but these errors were encountered: