OneSignal / onesignal-expo-plugin

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

[Bug]: Does not work unless OneSignal is the first plugin to modify notification settings on iOS #154

Open ansh opened 1 year ago

ansh commented 1 year ago

What happened?

I had two plugins that modified notification settings in my expo-dev-client SDK v47 app. I had "onesignal-expo-plugin" and "config-plugin-react-native-intercom" and a few others as well.

I followed the setup guides for OneSignal and Expo thoroughly. However, my app gave the Missing Push Capability error on the OneSignal dashboard.

The way I fixed it was moving onesignal-expo-plugin above all the other plugins that modified any notification settings.

Steps to reproduce?

1. Setup OneSignal on expo-dev-client app with this config plugin. Make sure APNS delegate fires.
2. Install another config plugin that modifies notifications settings like the Intercom config plugin (Intercom is a good example because OneSignal uses Intercom internally as well)
3. Build the app locally or using EAS
4. Open the app on a production device.
5. Check out the OneSignal dashboard and you will see the error "Missing Push Capability" alongside your device.

What did you expect to happen?

Push notifications should work, but they don't.

OneSignal Expo SDK version

"react-native-onesignal": "^4.5.0", "onesignal-expo-plugin": "^1.3.0",

Platform

iOS

Relevant log output

No response

Code of Conduct

rgomezp commented 1 year ago

@ansh , Thanks for reporting this. I'm happy you're able to find our workaround.

We are currently aware of this issue and have it documented in our setup guide (we specifically mention the order being important).

Ideally, we will be able to fix this in the future so it is not a requirement.

ansh commented 1 year ago

@rgomezp Oh! Where is it in the documentation? I must’ve misssed it.

ansh commented 1 year ago

This randomly stopped working again. Just randomly, no idea what happened. Super super frustrating! Even though OneSignal is the FIRST thing in the plugins array.

rgomezp commented 1 year ago

Hey Ansh. The documentation is here.

To debug, I recommend ejecting to a bare workflow and inspecting the capabilities files manually. See docs.

ansh commented 1 year ago

@rgomezp I did that and what I found was extremely odd. For some reason even if the OneSignal package is first, sometimes it works and sometimes it doesn’t work. It is quite odd but changing the order if it stops working and changing it back can be used as a workaround. That is however not a real fix at all. This needs to be addressed at a package level.

Eigilak commented 1 year ago

Agreed^^ We are also experiencing a lot of issues related to this πŸ‘Ž

[
        'onesignal-expo-plugin',
        {
          mode: 'x',
          devTeam: 'x',
          iPhoneDeploymentTarget: 'x',
        },
      ],
      '@config-plugins/react-native-blob-util',
      '@config-plugins/react-native-pdf',
      ['expo-build-properties', obj],
      ['config-plugin-react-native-intercom', obj],
      'react-native-health',
]

With expo config --type introspec i can confirm the onesignal entitlement is there

Thanks in advance

rgomezp commented 1 year ago

Howdy y'all. So to summarize, you're seeing issues even with the plugin being listed first. Is that correct?

Thanks for your patience while we investigate.

Eigilak commented 1 year ago

Correct πŸ˜…

brismithers commented 1 year ago

@Eigilak or @ansh would you be able to post the "Config Syncing" output of an expo prebuild that has failed to add the proper entitlements, with debugging enabled:

export EXPO_DEBUG=true
expo prebuild

The part of the output I'm interested in looks something like this:

- Config syncing
ios.entitlements: withDefaultBaseMods ➜ withIosBaseMods ➜ withGeneratedBaseMods ➜ withIosEntitlementsBaseMod
- Config syncing
ios.entitlements: withIosExpoPlugins ➜ withPlugins ➜ withStaticPlugin ➜ withAssociatedDomains ➜ withEntitlementsPlist
- Config syncing
ios.entitlements: withFallback ➜ withPlugins ➜ withStaticPlugin ➜ withNotificationsEntitlement ➜ withEntitlementsPlist
- Config syncing
ios.entitlements: withStaticPlugin ➜ withExpoContacts ➜ withRunOnce ➜ withAccessesContactNotes ➜ withEntitlementsPlist
- Config syncing
ios.entitlements: withStaticPlugin ➜ withExpoAppleAuthentication ➜ withRunOnce ➜ withAppleSignInWarning ➜ withEntitlementsPlist
- Config syncing
ios.entitlements: withPlugins ➜ withStaticPlugin ➜ withOneSignal ➜ withOneSignalIos ➜ withAppGroupPermissions ➜ withEntitlementsPlist
- Config syncing
ios.entitlements: withPlugins ➜ withStaticPlugin ➜ withOneSignal ➜ withOneSignalIos ➜ withAppEnvironment ➜ withEntitlementsPlist
- Config syncing
ios.entitlements: withConfigPlugins ➜ withPlugins ➜ withStaticPlugin ➜ withHealthKit ➜ withEntitlementsPlist
RL-Jurica-Penjgusic commented 1 year ago

Hi there, I have noticed same issue. When one signal plugin is set to first place and we have created eas credentials brand new, notifications are working. On second build, (probably due to "eas invalidates provision profiles"), notifications aren't working (missing push notification capability). Expo team accepted bug https://github.com/expo/eas-cli/issues/1069 but there no activity on this. I am working with EXPO_NOCAPABILITY_SYNC=1 option, but no luck either.

EtienneUku commented 1 year ago

Hello there !

If it can help, I wrote my own plugin to add iOS Share Extension (not yet publicly published) using your plugin as startup project base. When, at the end, I tried to run expo prebuild, either OneSignal or my plugin was not added to the targets in XCode. To solve this issue, I entirely removed all async code (nb: I don't use pods so this part was just removed anyway) in my plugin. Then guess what ? It always work.

To conclude, my guess is more related to async stuff done in OneSignal that might struggle if other plugins are doing the same.

Cheers !

RL-Jurica-Penjgusic commented 1 year ago

@rgomezp @brismithers Any chance to look solution from @EtienneUku ?

brismithers commented 1 year ago

@RL-Jurica-Penjgusic I have not been able to see plugins not getting included on expo prebuild for my testing apps. I've tried with various plugins and codebase sizes, thinking codebase size or number of plugins is a factor. If someone can provide a repo that reproduces this that would be super helpful. Alternatively, running expo prebuild with expo debugging enabled to get some insight into what expo is doing might be sufficient. Thanks!

RL-Jurica-Penjgusic commented 1 year ago

@brismithers Hi, today we ran at same issue, luckily expo debug was set to true. We have log of successfull build (no missing push capability ) and log of build that has missing push capability. So where can we send log files?

brismithers commented 1 year ago

@RL-Jurica-Penjgusic you can send the logs to support@onesignal.com, please reference this github issue in the email. Thanks!

brismithers commented 1 year ago

@RL-Jurica-Penjgusic logs received :)

brismithers commented 1 year ago

@RL-Jurica-Penjgusic unfortunately the debug logs isn't showing anything out of the ordinary. Both logs show all plugins being included during the prebuild phase, and the expected entitlement modifications are there (see below). Can you confirm whether the ipa file for the failing one has an entitlements file that includes what the prebuild has built up?

[PREBUILD]     entitlements: {
[PREBUILD]       'aps-environment': 'production',
[PREBUILD]       'com.apple.developer.applesignin': [
[PREBUILD]         'Default'
[PREBUILD]       ],
[PREBUILD]       'com.apple.security.application-groups': [
[PREBUILD]         'group.XXXXXXXXXX.onesignal'
[PREBUILD]       ]
[PREBUILD]     }
RL-Jurica-Penjgusic commented 1 year ago

Notifcation We get this from time to time

pettomartino commented 4 months ago

Any updates on making not requirement to have onesignal as top of the list?

I have 2 plugins fighting for this position :( what a nightmare

ansh commented 4 months ago

Which version of Expo are you on? @pettomartino

pettomartino commented 4 months ago

@ansh Expo 49

pettomartino commented 4 months ago

The issue I'm having is actually the one reported here