question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not receiving device token

See original GitHub issue

Using 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:34 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
EddyVerbruggencommented, Nov 30, 2018

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:

require("nativescript-plugin-firebase");
2reactions
rickybrowncommented, Nov 29, 2018

here is a fresh repo, following the instructions in NON_FIREBASE_MESSAGING.md: https://github.com/rickybrown/ns-angular-push

here are my logs, you’ll see on the fourth line down the token is undefined:

CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:13657:24: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
CONSOLE LOG file:///app/app/app.component.js:29:24: Registered for push
CONSOLE LOG file:///app/app/app.component.js:35:24: Current push token: undefined
[io.non.burnerchat] Requested authorization [ didGrant: 0 hasError: 0 hasCompletionHandler: 1 ]
[io.non.burnerchat] Requesting token for remote notifications
[io.non.burnerchat] Requested token for remote notifications [ didSucceed: 1 hasError: 0 hasCompletionHandler: 1 ]
[io.non.burnerchat] Requested authorization [ didGrant: 1 hasError: 0 hasCompletionHandler: 1 ]
[io.non.burnerchat] Requesting token for remote notifications
[io.non.burnerchat] Requested token for remote notifications [ didSucceed: 1 hasError: 0 hasCompletionHandler: 1 ]
[io.non.burnerchat] Did receive remote notification token
[io.non.burnerchat] Sending received device token to delegate UIApplication
[io.non.burnerchat] Did receive remote notification token
[io.non.burnerchat] Sending received device token to delegate UIApplication
HTHangEventCreate: HangTracing is disabled. Not creating a new event.

I’m running it on an iPhone X - same phone and bundle ID that the old push plugin works on

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not receiving push device token in… | Apple Developer Forums
The code works perfectly in release builds where I receive the device token as expected in the delegate method. I'm getting the exact...
Read more >
Not getting APNS Device token on ios 13 - Stack Overflow
In my case, I was getting a device token, but there is a delay in response (I think due to registering remote notifications...
Read more >
Android emulator does not receive the push token
This issue can occur when you test the mobile app that uses an Android emulator. You can connect to Acoustic Campaign and verify...
Read more >
Why is my device not receiving push notifications on iOS?
b) No token found​​ Go to iOS' settings → "Your app name" → Notifications to ensure notifications are enabled for your app. You...
Read more >
Push Notifications Troubleshooting & FAQ
The ExpoPushToken will never "expire" but if one of your users uninstalls the app, you'll receive a DeviceNotRegistered error back from Expo's servers,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found