Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
Angel21PC opened this issue Jun 6, 2023 · 1 comment
Closed
1 task done

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

Angel21PC opened this issue Jun 6, 2023 · 1 comment

Comments

@Angel21PC
Copy link

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

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Jun 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants