react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

Unable to Retrieve Device Token

Open Mimble-Wimble opened this issue 9 years ago • 3 comments

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);
}
...

Mimble-Wimble avatar May 17 '17 19:05 Mimble-Wimble

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.

nolan-m avatar Aug 16 '17 18:08 nolan-m

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.

stale[bot] avatar Jul 24 '19 23:07 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Aug 01 '19 00:08 stale[bot]