OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 373 forks source link

Cannot subscribe at all on Android, have tried the example app with same result #1366

Closed Rodrigo77777 closed 2 years ago

Rodrigo77777 commented 2 years ago

Description:

I'm encountering an issue with the new SDK where calling OneSignal.setAppId(); with the correct key for my app is not adding the user at all to the app (not showing on OneSignal web portal). No errors are shown on logcat or the app and it seems to have all gone through normally, but the user is never registered. Subsequent requests to subscribe return the following error on logcat:

03-02 11:59:55.148 17424 17592 E OneSignal: Waiting for remote params. Moving setSubscription() operation to a pending queue.

I followed the setup instructions thoroughly 3 times and no luck. Out of desperation I tried running the example app, again with my app id, and had the exact same result, nothing on web portal and no errors other than the above on trying to subscribe. I've tried this both on a device and an emulator, again same results I am at wits end with this. I've been using OneSignal with React Native for years with the previous SDK and this is a new app that was started from scratch on React Native 0.67 so I followed the (new) documentation for setup. I have no idea what is going on and I would really appreciate any help I can get on this. I have not yet tried iOS, as I need it to work on both and can't seem to get the simpler side (Android) to work.

I assume I must be doing something wrong here but having followed the documentation and having tried the example app with the same result, I have no idea what that might be.

Environment react-native 0.67.2 (same results on example app, which is on 0.64.1) react-native-onesignal 4.3.7 Android OS (both emulator and device returning same result)

Steps to Reproduce Issue:

  1. Create new app (such as example app) running new SDK
  2. Build and run on Android with appropriate App Id
  3. Run OneSignal.setAppId();. No errors will be returned, but user is not added on web portal for app
  4. Try subscribing, which will return the error detailed above.

Anything else:

Rodrigo77777 commented 2 years ago

Small Update:

Within the example app, clicking the "POST NOTIFICATION" button returns the following:

Attempting to send notification to undefined Failure: {"error":"Missing app_id"}

So clearly it's an App ID issue, but even with the following line unchanged from the example (or changed to reflect my own app id):

OneSignal.setAppId("ce8572ae-ff57-4e77-a265-5c91f00ecc4c");

The result is always the same. I've also tried downgrading to version 4.2.0 of the library, same result. I really don't understand what I'm missing here.

Rodrigo77777 commented 2 years ago

Some further info, here is the output of adb logcat -b all -d -v threadtime > onesignal_crash_logcat.txt when run on the example app. Content is too large to add here directly so will link to it.

WeTransfer link with onesignal_crash_logcat.txt

nan-li commented 2 years ago

Hi @Rodrigo77777,

It looks like there is a connection error when OneSignal requests the Android parameters as I see this stack trace below, and as a result, the device is not able to properly finish initialization and subscribe.

You may want to investigate this javax.net.ssl.SSLHandshakeException: Handshake failed exception. I did some testing on my end using your app ID and was able to subscribe an Android emulator to your app (you can check your OneSignal dashboard to see there is an Android phone subscribed). You can try on a different computer or network to help figure out what is going on.

03-03 19:18:47.506  9566 10170 D OneSignal: Starting request to get Android parameters.
03-03 19:18:47.506  9566 10221 D OneSignal: OneSignalRestClient: Making request to: https://api.onesignal.com/apps/f641d825-2ab9-42b4-a014-5086550e0163/android_params.js
03-03 19:18:47.512  1742 10222 E ResolverController: No valid NAT64 prefix (101, <unspecified>/0)
03-03 19:18:47.518  9566 10221 W OneSignal: OneSignalRestClient: null Error thrown from network stack. 
03-03 19:18:47.518  9566 10221 W OneSignal: javax.net.ssl.SSLHandshakeException: Handshake failed
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:288)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:196)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:153)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:30)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.onesignal.OneSignalRestClient.startHTTPConnection(OneSignalRestClient.java:206)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.onesignal.OneSignalRestClient.access$100(OneSignalRestClient.java:48)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.onesignal.OneSignalRestClient$4.run(OneSignalRestClient.java:116)
03-03 19:18:47.518  9566 10221 W OneSignal:     at java.lang.Thread.run(Thread.java:919)
03-03 19:18:47.518  9566 10221 W OneSignal: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xe3667a18: Failure in SSL library, usually a protocol error
03-03 19:18:47.518  9566 10221 W OneSignal: error:10000438:SSL routines:OPENSSL_internal:TLSV1_ALERT_INTERNAL_ERROR (external/boringssl/src/ssl/tls_record.cc:587 0xe36a24c8:0x00000001)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:387)
03-03 19:18:47.518  9566 10221 W OneSignal:     at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:226)
03-03 19:18:47.518  9566 10221 W OneSignal:     ... 17 more
03-03 19:18:47.522  9566 10224 I OneSignal: Failed to get Android parameters, trying again in 90 seconds.
Rodrigo77777 commented 2 years ago

Hey @nan-li thanks for looking into it and for your reply. After reading it, it immediately clicked what the issue was. My firewall (pfSense with pfBlockerNG) was blocking the requests being made to OneSignal. The OneSignal IP's are registered on one of the blocking lists and so my firewall was just killing the connection before it was established. I'm leaving this information here in case anyone ever runs into the same issue. Just temporarily disabling pfBlockerNG immediately resolved the issue.

Thanks for the help!