I'm trying to add push notifications GCM to my app but I can't get the sample project to work.
This is what I did:
+Registered project id and API key at Google
+Entered id and key in application-descriptor.xml like so:
< pushSender key="XXX"senderId="YYY">
+Deployed adapter
+Built the app ("Build all and deploy", Android SDK API 18, Google API 18)
And I have read http://www.ibm.com/developerworks/mobile/worklight/getting-started.html
Push notifications
Please tell me why? I can't write < pushSender key="XXX" senderId="YYY">
It is error but when I write < pushSender id="XXX" password="YYY"> It is ok.
I try to fill ID with SENDERID and PASSWORD WITH KEY but error when I run android amulator
This is invalid: <pushSender id="XXX" password="YYY">
This is valid: <pushSender key="XXX" senderId="YYY"/>
From what you are writing, the second option does pass the build, but fails in the Android Emulator; it likely fails for you because you did not properly configure the Android project for push notifications when tested in the Android Emulator - this is especially important as the configuration differs between device and emulator.
It'd help if you would've mentioned the error you're talking about...
You can follow full instructions in these question:
IBM Worklight - Push Notifications feature does not work in Android emulator
IBM Worklight 5.0.6.1 - Android notification does not reach either device or emulator
Related
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.
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. :)
I am new to IBM Worklight and I am trying to get push notification to work on my Android device.
I have followed the "Push notification in hybrid applications" tutorial on their website and imported the sample project.
The problem is somehow I didn't receive the push notification in my android device (haven't tried any other device yet). I didn't see any error in the console and it reported that the notifications has been sent to user.
Here is the log :
[2014-07-18 12:44:32] Starting procedure invocation on Worklight Server
[2014-07-18 12:44:33] Not deploying adapter 'PushAdapter' since it was not changed since last deployment
[2014-07-18 12:44:33] Invoking procedure: 'submitNotification' of adapter 'PushAdapter'
[2014-07-18 12:44:33] Server host: 192.168.1.100
[2014-07-18 12:44:33] Server port: 10080
[2014-07-18 12:44:33] Parameters: ["david","test message"]
[2014-07-18 12:44:33] Procedure invocation finished
And this is the report body:
{
"isSuccessful": true,
"result": "Notification sent to user :: david"
}
But I wait and wait and wait... and the notification still not arrived...
What I have done :
Read many SO question relevant to this topic like this and this (but still no luck)
Install Google Cloud Messaging Library for Android, although it has already obsolete, and Google Play services :
Generate API credential in google console (tried both browser key and android key)
Set key on application-descriptor.xml
Enable Google Cloud Messaging for Android and Google Play Android Developer API in google console project
turn off firewall
add google service lib as project reference
And i ran out of idea..
It seems my worklight console also didn't receive the push notification :
it shows 0 new messages and 0 total messages..
please help me.. i am losing hope.. any help would be very appreciated :) thanks in advance
Push Notifications in Worklight work for me when following the below instructions:
Installed Worklight Studio v6.2 from the Eclipse Marketplace
Downloaded and imported the Push Notifications sample project
Used my GCM ID and GCM Key in application-descriptor.xml
The GCM ID is the "project number". You can find it once logging into the GCM Console and into the project you create
The GCM Key is the "Browser" key you create in your GCM project under Credentials > Create key
Setup the Android SDK with Google API level 19 & Google Play Services
Created an AVD using the Google API (not to be confused with Android 4.4.2 level 19)
This is especially important: when testing in the Android Emulator you need to use the Google API and not the Android API
When testing in a physica device, you can use the Android API
Right-click on the adapter folder > Run As > Deploy Worklight Adapter
Right-click on the application folder > Run As > Run on Worklight Development Server
Right-click on the generated Android project > Run As > Android application
The AVD launches, application is installed
Logged-in with "Idan"
Right-click on the adapter folder > Invoke Worklight Adapter
Entered 'Idan','test notification' and clicked on the OK button
In the device, the alert()s from the application's JavaScript start popping, indicating the notification was received.
The above was tested in my home network, so I would suggest to double-check that you followed the above as well as check again your network settings. Take a look at slide #53 in the Push Notifications training module.
I'm trying to add push notifications to my app but I can't get the sample project to work.
This is what I did:
Downloaded sample project
Opened in Worklight 5.0.6
Registered project id and API key at Google
Entered id and key in application-descriptor.xml like so:
<pushSender key="XXX senderId="YYY"/>
Deployed adapter
Built the app ("Build all and deploy", Android SDK API 18, Google API 18)
Checked worklight console's Push Notifications tab (app and adapter are listed there) and the push notification tab
Started the app in android emulator (4.3)
In sample app, logged in with user "spyro", password "test"
Got an error:
Failed registering for push notifications. The application will not
be able to receive notifications
LogCat gives me the following messages:
10-22 06:07:11.178: E/SQLiteLog(2600): (14) cannot open file at line
30191 of [00bb9c9ce4] 10-22 06:07:11.178: E/SQLiteLog(2600): (14)
os_unix.c:30191: (2) open(/CachedGeoposition.db) - 10-22
06:10:58.392: W/WLDroidGap(2600): unregisterReceivers:Receiver not
registered: com.worklight.androidgap.plugin.Push$1#b419ff38 10-22
06:10:58.402: W/WLDroidGap(2600): unregisterReceivers:Receiver not
registered: com.worklight.androidgap.plugin.Push$3#b41a0458 10-22
06:10:58.442: E/PushApplication(2600): Error while trying to retrieve
device token from the mobile operating system.
I believe the following will resolve your problem, which is setting up push notifications in the Android Emulator; to have push notifications in the emulator it is required to install from the Android SDK Manager some support libraries.
First, make sure that you have followed all steps described in the Push Notifications training module, specifically slides 41 and 47.
Follow the steps described in the answer to this SO question:
IBM Worklight - Push Notifications feature does not work in Android emulator -- you must install the Google Cloud Messaging for Android Library (available in the Extras category)
In your updated question you do not mention whether you've installed the push notifications feature library, and you must install it.
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