React-native-notifications: Unable to Retrieve Device Token

Created on 17 May 2017  路  3Comments  路  Source: wix/react-native-notifications

I'm not able to retrieve a device token with the following bit of code. The project renders as expected and it prompts the user for permission to use Push Notifications, but it's not logging a device token. Any thoughts on what is incorrect?

import NotificationsIOS from "react-native-notifications";
...
module.exports = class App extends Component {
...
constructor(props) {
    super(props);
    if (Platform.OS === "ios") {
        NotificationsIOS.addEventListener('remoteNotificationsRegistered', this.onPushRegistered.bind(this));
        NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', this.onPushRegistrationFailed.bind(this));
        NotificationsIOS.requestPermissions();
    }
}

onPushRegistered(deviceToken) {
    console.log("Device Token Received", deviceToken);
}

onPushRegistrationFailed(error) {
    console.error(error);
}
...
bug iOcore 馃彋 stale

Most helpful comment

I was having this problem as well.

Error I receive on device is:

{
  domain: 'NSCocoaErrorDomain',
  localizedDescription: 'no valid \'aps-environment\' entitlement string found for application',
  code: 3000
}

Solution:

You need to enable push notifications in the Capabilities section of Xcode and have a App ID with Push Notifications enabled.

Follow the steps under "Enabling the Push Notification Service"
here https://www.raywenderlich.com/156966/push-notifications-tutorial-getting-started
if you need a guide.

All 3 comments

I was having this problem as well.

Error I receive on device is:

{
  domain: 'NSCocoaErrorDomain',
  localizedDescription: 'no valid \'aps-environment\' entitlement string found for application',
  code: 3000
}

Solution:

You need to enable push notifications in the Capabilities section of Xcode and have a App ID with Push Notifications enabled.

Follow the steps under "Enabling the Push Notification Service"
here https://www.raywenderlich.com/156966/push-notifications-tutorial-getting-started
if you need a guide.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

The issue has been closed for inactivity.

Was this page helpful?
0 / 5 - 0 ratings