IBM MobileFirst 8 - Push Notification errorCode: invalid_client - android

I am getting the following error while registering the device for push notification in android,
Failed to register
device:"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException:
Response: Status=400, Text:
{\"errorCode\":\"invalid_client\",\"errorMsg\":\"Incorrect JWT
format\"}, Error Message: Incorrect JWT format"
MFP Server: 8.0.0.00-20170220-1900
Cordova : 6.1.1
cordova-plugin-mfp : 8.0.201703309
cordova-plugin-mfp-push: 8.0.2017012410
Found the similar question but no clear figure :
IBM MobileFirst v8 trying to obtain Token on android cordova app after successful login challenge handler
Cordova Android application getting "invalid_client" from Mobile First 8.0 server
Any solution or suggestion will be appreciable.

Looks like you are missing the step in the android platform. In Android Studio, add the following activity to the application tag:
<activity android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNotificationHandler" android:theme="#android:style/Theme.NoDisplay"/>

The most common cause of the issue is failure in time synchronization between client and server. Verify if the server time if offset from the client. Specifically if the server has a time in past.

I had the same issue, Rebooting the client device / emulator helped me.
( The the "check server time" was not practical for me, my Server runs as Bluemix service in US )
BTW: I can reproduce this "Incorrect JWT format" in the android emulator: If the android emulator is running overnight and I try the next day, I always get this error (until restarting the emulator)

Related

Expo Push Notifications throwing internal stack error on Android Standalone build when calling getExpoPushToken()

Expo SDK 43.0
Expo-Notifications 0.13.3
Android Standalone build using Dev Client and EAS
Wondering if someone can give me a hand to understand what is going on with my Android build and getting a push token. I have followed the guides for both iOS and Android. Inclusive of adding in the FCM server key to expo. I can see it when I use the eas credential command and also if I just log into Expo.dev and look. However when I try to get an expo push token on an Android physical device, I receive this huge exception object that, unless I am missing something crucial, does not have any available information in it. I have attached a screenshot as has the object in it.
Screenshot of the error that I am receiving
As you can imagine, this works fine in iOS builds and fine in the Expo Go client. I also manually sent a notification/Campaign from firebase and every Android device with the application installed received it.

Socket.io not working in Ionic Android build

I'm trying to create an Android app with Ionic to send messages to a Node.js server. I'm using socket.io#2.3.0 for the server and socket.io-client#2.3.0 for the Ionic app. The Ionic app is supposed to open a socket.io connection with the server, then send the message "Hello, World!". The Ionic app build for the web works properly, I tried running it from other devices (my laptop and my phone) and in both cases the socket.io connection worked and the server printed out the message received from the Ionic app.
// Server output
Server running on port 5000.
New connection from 7rI7qvo9gNjVD5ElAAAA
Hello, World!
But when I build the Ionic app for Android using the commands:
ionic cap add android
ionic cap open android
And then debug from Android Studio, the app launches, but I don't see any message from the server, and I don't even see an error message in the Android Studio debug tab.
// Server output
Server running on port 5000.
At first I thought this was a network problem so I made sure the AndroidManifest.xml file included the permissions INTERNET and ACCESS_NETWORK_STATE, I tried building an APK and running it on my phone, but it still doesn't work so I don't know what I should do.
I'm using the version 5.4.16 of Ionic.
Thanks for reading this, have a nice day :)
I fixed this issue by hosting the Node.js server on Heroku, now everything works fine, I'm not sure why though. Since the protocol changes from http to https when I host the server on Heroku, I'm guessing Android doesn't like the http protocol.

MobileFirst 8 Android APP cannot connect to MobileFirst server after direct update

Here's the scenario:
Android device install WebResource Encrypt MFP APP.
Direct update web resource.
Restart this APP [ onDestory() -> onCreate() ]
Fail to connect MobileFirst8 Server
The logcat info:
We enable the follow features:
Certificate pinning
WebResource encrypt(mfpdev app webencrypt).
MobileFirst server version :
8.0.0.00-20170901-1903
Cordova MFP plugin version :
cordova-plugin-mfp 8.0.2017082110
cordova-plugin-mfp-push 8.0.2017082110
Update 1:
Even if we did not Direct Update web resource, just restart this app will fail to connect MobileFirst server.
The test scenario:
cordova prepare
mfpdev app webencrypt (with certificate pinning)
debug on android device
first run works fine. but fail to connect when reload this app
Here's the device log when APP restart:
MFP server version : 8.0.0.00-20170901-1903
mfpdev-cli version : 8.0.0-2017080206
cordova-plugin-mfp version : 8.0.2017090705
device info : Android 7.0
Test project source code : GitHub link
Please check if the certificate you are looking for is available in the 'certificates' folder. The error message suggests that the certificate does not exist in the specified location.
The case of direct update not working when WebResourcesEncryption is enabled, has been fixed via APAR PI84522:
Install the latest iFix to resolve the issue.
The case has been fixed via PI88636
Use cordova-plugin-mfp 8.0.2017102115 to resolve the issue.

Worklight 6.2: Successful sent tag push notification but not received at android devices

Im having issues to receive push notification on android devices. I am using tag based notification using Worklight 6.2. Below is the steps used to create the apps.
Create hybrid apps
Import the example into Eclipse
Create new environment (Android)
Create a new project in GCM and get the required credentials (server key)
key in App ID(project no) and api key(server key) in application-descriptor.xml file
Run all environment.
Create the .apk files and import into android devices.
Run Android emulator using API19 Google Apis.
Successfully subscribe to event tag
Invoke adapter procedur (sendTagNotification)
After invoke adapter procedure, I did check the logcat and no errors found. Can anyone help me. Below is the snippet of logcat after i invoke the procedure.
01-14 05:28:31.153: D/HttpPostRequestSender(1951): HttpPostRequestSender.run in HttpPostRequestSender.java:46 :: Sending request https://amrs.malaysiaairports.com.my:444/SimpleProject/apps/services/api/SimpleProject/android/heartbeat 01-14 05:28:32.193: D/NONE(1951): response [https://amrs.malaysiaairports.com.my:444/SimpleProject/apps/services/api/SimpleProject/android/heartbeat] success:
Thanks!
From the comments:
its solved already. I forgot 1 step to build for worklight environment. After I build to Worklight environment, its done. :)

IBM Worklight and push notifications issue

I've deployed an Android application on a real device using IBM Worklight.
I've enabled the push notifications and all works on the Android emulator, but on the real device I see this popup:
Failed registering for push notifications. The application will not be
able to receive notifications.
And in LogCat, this message:
Push notification will not work, because register/unregister to GCM
service returned error AUTHENTICATION_ERROR
On the android device the same gmail account of the senderId is syncronized.
My Environment:
Worklight Studio 5.0.6
Eclipse Java EE IDE for Web Developers. Version: Juno Service Release 1 Build id: 20120920-0800
Windows7
Android 2.3
I've checked the behavior with:
Android 4.2 Smartphone
Android 4.1 Smartphone
Android 3.1 Tablet
Android 2.3 Smartphone
I'm not able to subscribe the application for push notifications only with the 2.3 Android version.
Push Notifications in Worklight with the Android environments are supported starting Android OS 2.2 and above (2.2.x, 2.3.x and 4.x.x. Worklight does not support Android OS 3, but it should work there with Worklight none the less).
From another SO question: HTTP Status Code: 401 in GCMDemo
Authentication ErrorThe sender account that you're trying to use to
send a message couldn't be authenticated. Possible causes are:
Authorization header missing or with invalid syntax.
Invalid project number sent as key.
Key valid but with GCM service disabled.
Request originated from a server not whitelisted in the Server Key
IPs.
I would re-validate all required settings, in this case: Gmail address and password in the device, and senderId and Key in application-descriptor.xml

Categories

Resources