Push Notifications with detached expo app

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 🚧 PushNotificationIOS · React Native

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?

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

1 Like

Hi @ccheever , Currently iam detached my application, In android the token generate’s, But in IOS the token was not generated. Can u help me to resolve this issie

Hi @saravana_1995, are you asking for user permission before trying to get the token on iOs?

Anyway, for detached apps it’s really efficient to use OneSignal instead expo notification, like @ccheever said. One signal works just like Expo in some ways, but you have so more tools do send em control your users, think about that.