Not receiving device token
See original GitHub issueUsing with Vue nativescript.
Am not getting the device token after allowing push notification. This is how my main.js looks like
import { messaging, Message } from “nativescript-plugin-firebase/messaging”;
Vue.prototype.$router = router
Vue.prototype.$goto = function (to, options) { this.$navigateTo(this.$router[to], options) }
console.log(messaging);
messaging.registerForPushNotifications({ onPushTokenReceivedCallback: (token) => { console.log("Firebase plugin received a push token: " + token); },
onMessageReceivedCallback: (message) => {
console.log("Push message received: " + JSON.stringify(message, getCircularReplacer()));
},
showNotifications: true,
showNotificationsWhenInForeground: true
}).then(() => console.log(“Registered for push”));
messaging.getCurrentPushToken()
.then(token => console.log(Current push token: ${token}
));
[org.nativescript.events-mobi] Requested authorization [ didGrant: 1 hasError: 0 hasCompletionHandler: 1 ] [org.nativescript.events-mobi] Requesting token for remote notifications [org.nativescript.events-mobi] Requested token for remote notifications [ didSucceed: 1 hasError: 0 hasCompletionHandler: 1 ] [org.nativescript.events-mobi] Did receive remote notification token [org.nativescript.events-mobi] Sending received device token to delegate UIApplication HTHangEventCreate: HangTracing is disabled. Not creating a new event. removing all entries config 0x280898840 Task <AC441F95-9987-40C1-B67B-46050D2CF432>.<1> resuming, QOS(0x19) TIC TCP Conn Start [4:0x283dd3240]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:34 (8 by maintainers)
Top GitHub Comments
Damnit, I forgot to document quite an important piece of the puzzle to make this work (sorry!):
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/d6cc3cc91bd71800b1b7e9d75460682515e58ce4/demo-push/app_resources/iOS/Info.plist#L50-L51
You can try adding that to your project and it’ll work. I’m currently considering the best way to either automate or document this.
@rickybrown In your case you also need to add this to
main.ts
so the iOS appdelegate can be wired correctly (this bit is actually documented, lol) - I’ve sent a PR to your repo:here is a fresh repo, following the instructions in
NON_FIREBASE_MESSAGING.md
: https://github.com/rickybrown/ns-angular-pushhere are my logs, you’ll see on the fourth line down the token is undefined:
I’m running it on an iPhone X - same phone and bundle ID that the old push plugin works on