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.

iOS - registerForPushNotifications not resolved.

See original GitHub issue

Plugin version: 10.4.0

import * as firebase from 'nativescript-plugin-firebase';

async function register () {
    if (!firebase.areNotificationsEnabled()) {
        console.log('Attempt to register...');

        await firebase.registerForPushNotifications({
          showNotifications: true,
          showNotificationsWhenInForeground: true
        });

        console.log('Status', { enabled: firebase.areNotificationsEnabled() });
    }
}

Console output:

...
Webpack compilation complete. Watching for file changes.
Webpack build done!
Project successfully prepared (ios)
Installing on device 12345678-90AB-CDEF-1234-567890ABCDEF...
Successfully installed on device with identifier '12345678-90AB-CDEF-1234-567890ABCDEF'.
Successfully transferred all files on device 12345678-90AB-CDEF-1234-567890ABCDEF.
Restarting application on device 12345678-90AB-CDEF-1234-567890ABCDEF...
CONSOLE INFO file:///node_modules/nativescript-dev-webpack/hot.js:3:23: HMR: Hot Module Replacement Enabled. Waiting for signal.
NativeScript debugger has opened inspector socket on port 18183 for com.test.app.
Successfully synced application com.test.app on device 12345678-90AB-CDEF-1234-567890ABCDEF.
CONSOLE LOG file:///node_modules/@nativescript/core/inspector_modules.js:1:12: 'Loading inspector modules...'
CONSOLE LOG file:///node_modules/@nativescript/core/inspector_modules.js:6:12: 'Finished loading inspector modules.'
NativeScript debugger attached.
CONSOLE LOG file:///app/store/notifications.js:5:8: 'Attempt to register...''

The promise never seems to resolve. The prompt itself does appear, and if i restart the app and check again, firebase.areNotificationsEnabled() does return true/false.

Am I doing anything wrong?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
b3nm4rcommented, Feb 27, 2020

@EddyVerbruggen I think this is relevant: I tried following the instructions for 3rd party providers (non-firebase messaging), and I cannot get the promise to resolve or the onPushTokenReceivedCallback to fire on iOS. Everything with the capabilities and the info.plist seem to be correct.

I have put together a bare-bones Nativescript-Vue app with nativescript-plugin-firebase in a public repository, and using this repo I have the problem described above.

I looked into your code and found that the entitlements file is missing. Please also enable push support and copy the entitlements file to App_Resources, as described here.

0reactions
manojdcodercommented, Mar 7, 2020

@Firetrip Have you setup APN certificates / authentication keys? Did you make sure you running on right environment (Development / Release)? Is your device network having any restrictions?

There may not be any issues with Simulator as Push Notification really doesn’t work on Simulator, neither require any configuration there like you do on device.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No answer from registerForPushNotifications() on Appcelerator
Try it on a real device, push notification does not work on the iOS Simulator. – danny005. May 3, 2016 at 15:04. Add ......
Read more >
Not receiving push device token in… | Apple Developer Forums
Hi there, I'm seeing weird behavior when trying to register for push notifications in macOS development builds for any of my apps
Read more >
Push Notification Troubleshooting for iOS - Braze
No push registration prompt. If the application does not prompt you to register for push notifications, there is likely an issue with your...
Read more >
iOS notifications missing - Issues / Bugs - Thunkable Community
When you go into iOS Settings > Notifications the app is not listed. ... Make sure to call registerForPushNotifications if you have disabled...
Read more >
iOS SDK Setup - OneSignal Documentation
Instructions for adding the OneSignal SDK to your iOS native app with Swift or Objective-C. ... Unless you have a specific reason not...
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