OneSignal / onesignal-expo-plugin

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

[Bug]: Push notifications on IOS do not work properly #186

Closed Angel21PC closed 1 year ago

Angel21PC commented 1 year ago

What happened?

Hello everybody, I have implemented OneSignal in my React-Native application with Expo, but I have a problem. Not always when I do a deploy they work correctly (right now they don't work for me). I use Expo to make my deploy and send the compilation to Apple, plus he takes care of creating the certificates (except for the notification key). This has worked before but not every time I do a deoploy. Am I missing something ? Is there some kind of bug with the implementation ? (No Recipients appears in the OneSignal panel) The OneSignal plugin in the first place:

 "plugins": [
      [
        "onesignal-expo-plugin",
        {
          "mode": "production"
        }
      ],
      [
        "expo-location",
        {
          "locationAlwaysAndWhenInUsePermission": "Allow Planeta Huerto to use your location."
        }
      ]
    ]

Class to use the library:

class OneSignalNotificationService implements INotificationProviderEntity {
  initialize(): void {
    OneSignal.setAppId(configApp.notifications.oneSignalAppId);
    OneSignal.promptForPushNotificationsWithUserResponse();
  }
  handleNotificationsReceived(): void {
    //Method for handling notifications received while app in foreground
    OneSignal.setNotificationWillShowInForegroundHandler(
      (notificationReceivedEvent: any) => {
        let notification = notificationReceivedEvent.getNotification();
        // Complete with null means don't show a notification.
        notificationReceivedEvent.complete(notification);
      }
    );
  }
  handleNotificationsOpened(): void {
    //Method for handling notifications opened
    OneSignal.setNotificationOpenedHandler((notification: any) => {
      const data = notification.notification.additionalData;
      if (data) {
        EventBus.emit("openNotification", data);
      }
    });
  }
}

Call:

const App = () => {
  const notificationService: INotificationService =
    new OneSignalNotificationService();

  notificationService.initialize();
  notificationService.handleNotificationsOpened();
  notificationService.handleNotificationsReceived();

Steps to reproduce?

Install the OneSignal library in an expo project and deploy.

What did you expect to happen?

Push notifications should work

OneSignal Expo SDK version

"onesignal-expo-plugin": "1.0.2", "expo": "~48.0.10", "react-native-onesignal": "^4.5.1"

I know it's not the latest version, but with this one it worked. Even so, I have updated the libraries in several tests and nothing.

Platform

iOS

Relevant log output

No response

Code of Conduct

emawby commented 1 year ago

@Angel21PC Hello thank you for reaching out can you clarify what issues you are seeing with the deploy?