OneSignal / onesignal-expo-plugin

The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.
Other
142 stars 46 forks source link

[Bug]: Not receiving Push Notifications on iOS #199

Open craigwendel opened 9 months ago

craigwendel commented 9 months ago

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!

Screen Shot 2023-09-25 at 12 49 16 PM Screen Shot 2023-09-25 at 12 55 38 PM

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

TierryBr commented 7 months ago

I have the same problem

darmoment commented 5 months ago

Did anyone ever figure this out?

smail-aouissa commented 4 months ago

Same here

michelazzam commented 2 months ago

Same here!

In app notification works fine. But the push notification isn't working

QB3L commented 1 month ago

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?)

qb3l-pplsi commented 1 month ago

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)
    })
bilalkashif26 commented 4 days ago

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.

Note that you have to add push notifications capability while creating a new key in apple developer console of your app

Screenshot 2024-06-28 at 12 14 55 PM