onesignal-expo-plugin
onesignal-expo-plugin copied to clipboard
[Bug]: Not receiving Push Notifications on iOS
What happened?
I followed this guide for setting up my project with OneSignal for notifications but I'm not receiving any notifications at all for my build I pushed to iOS. I feel like I set up everything correctly and have the correct .p8 certificate that's integrated with Expo and my developer account on Apple but I'm always seeing the same Failed error below. Anyone else run into any issues like this? I've tried working with the Support team at OneSignal but so far no luck and it's usually hours before they respond to my questions. Thanks again!
Steps to reproduce?
1. Install the Expo plugin as demonstrated by this guide https://documentation.onesignal.com/docs/react-native-sdk-setup
2. Have user subscribe to Notifications in production app build in iOS
3. Send out Push Notification message from OneSignal Dashboard to Subscribers
What did you expect to happen?
I expected to receive a push notification on my device with the content I sent out from the OneSignal dashboard
OneSignal Expo SDK version
2.0.0
Platform
iOS
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I have the same problem
Did anyone ever figure this out?
Same here
Same here!
In app notification works fine. But the push notification isn't working
Same exact issue. Verbose logs don’t show anything. Devices seem to be registering fine as well. I’m not used to using p8 key for setup but it should work for both sandbox and production. I’m not clear when OneSignal uses one over the other though (what is it looking at to differentiate?)
For reference. Testing with the simple code below correctly sends and receives a notification so it seems the app setup is correct. I encourage everybody to try the same
const apn = require('apn')
const provider = new apn.Provider({
token: {
key: './my_p8_file.p8', // Path to the .p8 file
keyId: 'MY_P8_KEY_ID', // The Key ID associated with the .p8 file
teamId: 'MY_TEAM_ID', // The Team ID associated with your Apple Developer account
},
production: false, // false for development
})
// Create a notification
const notification = new apn.Notification()
notification.alert = 'Hello, this is a test push notification!'
notification.sound = 'default'
notification.topic = 'com.acme.come' // Replace with your app's bundle ID
// Replace with the device token you want to send the notification to
// In OneSignal, this is called the "Push Token" and you need to enable
// the column to see it under Audience -> Subscriptions
const deviceToken = '<DEVICE_PUSK_TOKEN>'
// Send the notification
provider
.send(notification, deviceToken)
.then((result) => {
console.log(result.sent.length)
console.log(result.failed.length)
console.log(result.failed)
})
.catch((error) => {
console.log('ERROR:', error)
})
I ran into the same problem a few weeks ago and after verifying the code and all other things, I've tried to revoke the .p8 key in the Apple developers account, creates a new one, and add it to one signal in IOS Platform. And push notifications started working.
- Upload your .p8 file
- Add your newly created key
- Add your team ID
Note that you have to add push notifications capability while creating a new key in apple developer console of your app