pusher / push-notifications-android

Android SDK for Pusher Beams
https://www.pusher.com/beams
MIT License
21 stars 21 forks source link

W/PushNotificationsAPI( 8126): Failed to register device: NOKResponse(error=Something went wrong, description=Device could not be created) #147

Closed dankhan-helmet closed 1 month ago

dankhan-helmet commented 1 month ago

Hi,

Having some trouble getting pusher beams to work on Android Emulator in flutter for a new app. I assume it should work fine on the emulator?

Error messages in log:

Connecting to VM Service at ws://127.0.0.1:54264/eRpYliPUyG0=/ws
[5] W/PushNotificationsAPI( 8422): Failed to register device: NOKResponse(error=Something went wrong, description=Device could not be created)
D/com.pusher.pusher_beams.PusherBeamsPlugin@ba63f03( 8422): PusherBeams started with <instance-id> instanceId
D/com.pusher.pusher_beams.PusherBeamsPlugin@ba63f03( 8422): Returning initial data: null

Not sure if this is related, but when it repeats the message it also includes these lines above the NOK Response line - which all have denied access:

D/TrafficStats( 8997): tagSocket(84) with statsTag=0xffffffff, statsUid=-1
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/ConscryptEngineSocket;->setUseSessionTickets(Z)V (max-target-q,core-platform-api, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setUseSessionTickets(Z)V (max-target-q,core-platform-api, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/AbstractConscryptSocket;->setUseSessionTickets(Z)V (max-target-q, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/ConscryptEngineSocket;->setHostname(Ljava/lang/String;)V (max-target-q,core-platform-api, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setHostname(Ljava/lang/String;)V (max-target-q,core-platform-api, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/AbstractConscryptSocket;->setHostname(Ljava/lang/String;)V (max-target-q, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (max-target-q,core-platform-api, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/AbstractConscryptSocket;->setAlpnProtocols([B)V (max-target-q, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (max-target-q,core-platform-api, reflection, denied)
W/p.app.mobile( 8997): Accessing hidden method Lcom/android/org/conscrypt/AbstractConscryptSocket;->getAlpnSelectedProtocol()[B (max-target-q, reflection, denied)
W/PushNotificationsAPI( 8997): Failed to register device: NOKResponse(error=Something went wrong, description=Device could not be created)

Happens before my PusherBeams.instance.start() call, so maybe a problem setting up the pushnotification libraries correctly?

Anyone else run into this? Thought I was following the instructions so far, but maybe there's some other incompatibility/initialisation issue. I'm using the latest plugins. Also tried with the versions listed on the readme page here, same results.

My flutter setup detailed below thanks for any help.

...
dependencies {
    implementation 'com.google.firebase:firebase-messaging:24.0.0'
    implementation 'com.google.firebase:firebase-installations:17.1.0'
    implementation 'com.pusher:push-notifications-android:1.9.2'
}

apply plugin: 'com.google.gms.google-services'
dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.4.1'
    }

Trying to run this both through flutter and android studio produces same results. Manifest allows outgoing connections and verified I can connect to web from the emulator so I don't think it's a connection problem.

<uses-permission android:name="android.permission.INTERNET"/>    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
        android:usesCleartextTraffic="true"
        android:enableOnBackInvokedCallback="true">
 </application>

flutter doctor -v output:

[✓] Flutter (Channel stable, 3.19.2, on macOS 13.6.4 22G513 darwin-arm64, locale en-NZ)
    • Flutter version 3.19.2 on channel stable at /Development/Projects/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7482962148 (3 months ago), 2024-02-27 16:51:22 -0500
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/xxx/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/xxx/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554             • android-arm64  • Android 14 (API 34) (emulator)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
knatnaela commented 1 month ago

Any update on this?

dankhan-helmet commented 1 month ago

Thanks for following up, not quite sure what changed, but finally started building and connecting to the gateway again. Not sure if the gateway was down, but the error message wasn't particularly helpful, and a bit unclear where the actual error was being thrown. After switching emulators and rebuilding a bunch of times and giving it lots of time, I finally saw the registering FCM token message and all was good after that. Sorry I can't be clearer, problems like this always hard to track down.