Notification message not shown when app is in the background
See original GitHub issueHi, 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:
Content-Type:application/json
Authorization:key=[MY_AUTH_KEY]
JSON:
{
"to" : "[MY_FIREBASE_KEY]",
"content_available": true,
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"click_action": "helloworld",
"icon": "notification_default",
"sound" : "default",
"priority": "high",
"badge": 1
}
}
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:
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { AppModule } from "./app.module";
import firebase = require("nativescript-plugin-firebase");
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.dump(message);
console.log("Title: " + message.title);
console.log("Body: " + message.body);
// if your server passed a custom property called 'foo', then do this:
// console.log("Value of 'foo': " + message.foo);
}
}).then(
(instance) => {
console.log("firebase.init done");
},
(error) => {
console.log("firebase.init error: " + error);
}
);
platformNativeScriptDynamic().bootstrapModule(AppModule);
Issue Analytics
- State:
- Created 7 years ago
- Comments:57 (25 by maintainers)
Top GitHub Comments
@sudhanshu-15 I’m looking at this later today with the demo app.
@simonettoa You’re doing everything right, except you need to remove
<key>FirebaseAppDelegateProxyEnabled</key><false/>
from app/app_resources/ios/xx.plist