push notification example pushnotifications34 is not working

the push notification example in
https://docs.expo.io/versions/latest/guides/push-notifications/
is not working.

there were somebody encountering the same thing before:

it’s still the same as of now (using iOS expo). has this problem been ever addressed?

thanks

1 Like

Hey @beechow,

I just ran the Snack and it is working for me. Can you let me know what version of iOS your device is running as well as what version of the Expo client you are running?

Cheers,
Adam

Hi. I just open directly from snack.
my iOS version is 12.3.1, on 6s Plus.
thanks a lot.

Can you elaborate on what you mean by “it is not working”?

I’m having the same issue. The snack is setup on my phone, notifications are enabled, but nothing appears and the text doesn’t update where it displays Origin and Data. Any suggestions?

So after a couple of hours trying to get this working, I realised that

const message = {
			to: YOUR_PUSH_TOKEN,
			sound: 'default',
			title: 'Original Title',
			body: 'And here is the body!',
			data: { data: 'goes here' },
		};

Needs to contain to: ExponentPushToken[], for some reason the code doesn’t include that or mention that you cant just pass in the actual token. I guess it would also work to use const YOUR_PUSH_TOKEN = 'ExponentPushToken[ho98SdEpcYgEG8tw5UtUft]'; for example.

However, I chose to use this approach:

const YOUR_PUSH_TOKEN = 'ho98SdEpcYgEG8tw5UtUft';
// code inbetween
const message = {
			to: "ExponentPushToken[" + YOUR_PUSH_TOKEN + "]",
			sound: 'default',
			title: 'Original Title',
			body: 'And here is the body!',
			data: { data: 'goes here' },
		};

Also: this guide helped me figure this out, hopefully it can help other people as well stuck on push notification.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.