Closed nimda1902 closed 3 years ago
Hi, Thanks for providing information to look into the problem you have faced.
In exception details Invalid device token
is from server.
Specially in case of apns2: If token(/deviceId) is of invalid length then server throws error with message Expected 32 or 100 byte hex device token
but since you are receiving message of invalid token- It should be issue of invalid characters in deviceId.
So I would request you to verify once that deviceId is correct/ the same which you intended to pass when the condition meets for PusGateway apns2 type.
the token is from firebaseMessaging.getToken()
, how could i verify it?
Seems like It's fcm/gcm
token and with ios simulator the method call is happening with PushGateway.apns2
argument so for apns2 type, the token is invalid.
@mohitpubnub it is possible embed Firebase into iOS application and use it's own tokens with Firebase console. It looks like, under the hood Firebase SDK does exchange of actual device token (the one, which usually iOS application use) on Firebase token (which looks similar to the one, which you will get on Android).
@nimda1902 is it possible to show at leats portion of output from firebaseMessaging.getToken()
?
But @mohitpubnub is correct, if there will be FCM-like token (for me it looks like JWT), then you will need to use other type during registration (for FCM
).
@parfeon , yes it's JWT. fB1ukAscToCON1IJU_vs3X:APA91bF0dJU...
.
Already change to DeviceInfoPlugin to get unique id, but still got same error.
String deviceId = Platform.isAndroid ? (await deviceInfoPlugin.androidInfo).androidId : (await deviceInfoPlugin.iosInfo).identifierForVendor;
It doesn't look like hexadecimal. With apns2
, valid hexadecimal device-token is expected.
Hi @nimda1902 , were you able to resolve this ? I am getting the same error.
@mohitpubnub How do we resolve it in react native app. Getting same error. I am using Javascript SDK.
Hi ,
i got error when try to add push channel on IOS simulator.
`PubNubException: null error: Invalid device token
0 new PubNubException (package:pubnub/src/core/exceptions.dart:9:29)
my code
await pubnubApp.pubnub .addPushChannels( await _firebaseMessaging.getToken(), Platform.isIOS ? pn.PushGateway.apns2 : pn.PushGateway.gcm, channels, environment: AppConfig.appMode == 'devel' ? pn.Environment.development : pn.Environment.production, topic: 'mytopic')
flutter doctor -v
`[✓] Flutter (Channel stable, 1.22.2, on Mac OS X 10.15.7 19H2, locale en-GB) • Flutter version 1.22.2 at /opt/flutter • Framework revision 84f3d28555 (25 hours ago), 2020-10-15 16:26:19 -0700 • Engine revision b8752bbfff • Dart version 2.10.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/md.nurfikri/Library/Android/sdk • Platform android-30, build-tools 29.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.0.1, Build version 12A7300 • CocoaPods version 1.9.3
[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 44.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] IntelliJ IDEA Community Edition (version 2020.1.4) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 48.1.3 • Dart plugin version 201.9002
[✓] VS Code (version 1.50.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.15.1
[✓] Connected device (2 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator) • iPhone 11 Pro Max (mobile) • 8700980D-5E58-4DC4-BD02-CC06CA7FA3DE • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
• No issues found!`