Push Notifications with detached expo app

#1

Im trying to implement push notifications using Expo. It worked before I detached my app. No Im trying to get the native device token using Expo. (I’ve also tried Permissions.REMOTE_NOTIFICATIONS.

Permissions.askAsync(Permissions.NOTIFICATIONS).then(status => {
	  if(status === 'granted') {
		Notifications.getDevicePushTokenAsync()
			.then(token => {
				Alert.alert(
					'This is your token',
					`${token}`, [{text: 'OK', onPress: () => console.log('OK Pressed')},], {cancelable: false}
				);
				this.setState({token});
			})
			.catch(err => {
				this.setState({error: err.toString()});
			});

		Notifications.getExpoPushTokenAsync()
			.then(token => {
				Alert.alert(
					'This is expo token',
					`${token}`, [{text: 'OK', onPress: () => console.log('OK Pressed')},], {cancelable: false}
				);
			})
			.catch(err => {
      console.log(err);
			})
	  }
	});

I never receive the device token. Any thoughts?

I’ve also tried to implement PushNotificationIOS https://facebook.github.io/react-native/docs/pushnotificationios.html#content

But I get build errors in the native xcode project. Saying it could not find file #import <React/RCTEventEmitter.h>

This works fine when I create a new react-native init project and implement PushNotificationIOS

Any thoughts?

[solved] android receive data from a fcm-push notification in detached app
#2

hi-

you’ll need to use your own push notification pipeline if you detach because we can’t manage your certificates and keys etc and keep the expo keys private at the same time.

lots of people use OneSignal for this. https://onesignal.com/

good luck!

charlie