push notification IBM MobileFirst 7 - ibm-mobilefirst

I have written IBM Adapter for push notification.I able to fetch device Id from device using 'WL.Device.getID'.I want to send push notification on the device but there is no way to subscribe.and did not find a way to subscribe push notification Event source in java adapter as mentioned in demo javaScript adapter. When I called sendMessage() method through pushApi , I got exception that PushApplication was not found.
Also to handle the challange , we use WorklightProtocolAuthenticator .
Please help how i can send push notification using java based push adapter.
Below is my adapter :-
WLServerAPI api = WLServerAPIProvider.getWLServerAPI();
PushAPI pushApi = api.getPushAPI();
INotification noti = pushApi.buildNotification();
noti.getTarget().setDeviceIds("a5be4b35-b278-3014-b933-ce99a8l87819");
noti.getMessage().setAlert("text to be send on device");
pushApi.sendMessage(noti, "ApplicationId");
And how can i get this ApplicationId.

Please help how i can send push notification using java based push adapter.
You do not find what you are looking for because AFAIK it does not exist. The APIs are available only in JavaScript.

Related

Use variable in a Parse Push message

I really like the Parse push service and integrated it with our CMS. I would like to make the notifications personal by adding the users name in the push message. How can i use a variable (Named 'voornaam' in the screenshot) which is stored in the Installation class in a push message?
If you are looking for something like a message template like
Hello ${username}, what's up
sadly its not there. One way you can make the kind of message you want to is by doing it in your server side code before you send the request for PUSH using the REST or other APIs

PushSharp "Notification send timed out" issue

I am trying to use PushSharp to send notification to my mobile devices using Google Gcm.
I downloaded the sample application from github depending upon that I have written my sample code. below is my sample code.
var googleKey = CustomConfigurationManager.GetValueFromSection("appSettings", "GoogleServerAccessKey");
AndroidPushBroker.RegisterGcmService(new PushSharp.Android.GcmPushChannelSettings(googleKey));
GcmNotification androidNotifcation = new GcmNotification().WithDryRun()
.WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.caf\"}");
AndroidPushBroker.QueueNotification(androidNotifcation);
The issue is though I have used WithDryRun() and upon hooking up request it shows json data with "dry_run": true, but still I receive Notification failed error with reason : "Notification send timed out".
Anybody can tell me what am I missing ?
try to run it without WithDryRun(), and see do you get anything in events like NotificationSent, ChannelException, NotificationFailed or ServiceException.

sending gps data using icomsat v1.1

I am doing my final year project that tracks the vehicle and displays the position on google maps,am using an arduino,GPS module and icomsat v1.1 GPRS module.Am trying to send the GPS data to a web page at my local server with no success,how do i do this, pls help :
this is how am doing it:
//set http param value
GPRS.print("AT+HTTPPARA=\"URL\",\"http://my_domain/gps_tracker.php?");
GPRS.print("visor=false");
GPRS.print("&latitude=");
GPRS.print(latitude);
GPRS.print("&longitude=");
GPRS.print(longitude);
GPRS.print("speed=");
GPRS.print(speedOTG);
GPRS.print("\"");
I suppose that you need to send the url as a single line message, using: println instead of print.
And check if you're receiving or not any data on your GPRS module, or if you're not managing it right.

IBM Worklight: Extend Server-side Java Code

Can I extend the server-side Java Code in Worklight?
For example, there is a class called JavaScriptIntegrationLibraryImplementation under com.worklight.integration.js. Inside this class, there is a method broadcastNotification and I would like to override this method. Is it possible to do so?
EDIT
The reason is that:
When I make the subscription in client side with option field (e.g. add customType: A), I would like to retrieve a list of devices which have been subscribed to this event source. Base on the option field in deviceSubscrpition, I would like to have some business logic to determine who to send the notification message. For example, I will only submit the message to the user which 'customType=A'.
However, there is no API in Worklight which can retrieve a list of devices which make me to retrieve the list first. Then do the logic in JavaScript and called WL.Server.notifyDevice..
Therefore, I would like to check whether there is any method to retrieve a list of devices (through API / Adapter which connects to DB) which have subscribed to an event source.
Thanks.
This part of Worklight is not extendable. You can try and override this method as you say, but do note this is not supported and we cannot help in this case.
Edit
Now that it is clear what you're trying to achieve... what you are looking for currently not available. I will open a feature request for it and it will get evaluated at some point (if you are a customer of IBM, I suggest to get in touch with your contact...).
My suggestion (somewhat hackish in form): you could perhaps use multiple Event Sources, where each event source represents an iOS version. On the client-side, upon app initialization, you can retrieve the iOS version and use it to register to the correct event source (this would be very generic code to allow re-use). In case a new iOS version is released (you will likely know of this in advance), you simply add this event source to the adapter code and re-deploy the adapter. Users of the new iOS version could still register for notification, because you get the iOS version upon init, and use this information to register to the correct event source...
To reiterate:
The adapter contains: ES_iOS5 ES_iOS6
The client:
fetches iOS version, stores it in some variable.
registers to event source, where event source name is ES_${iOSVersion}
if a new iOS version is released, simply create a new event source and re-deploy
the adapter; the client is already equipped to handle this.
#Red23jordon,
i had similar case, i created a custom table where at the time of subscription, I was saving
user ID and event type in custom table. and when user unsubscribe then i also remove details from custom table.
For sending push to users subscribed to a particular "even type" i look into custom table to get list of user IDs subscribed to particular event type, and then i went into Notification user/device tables and fetching corresponding devices and sending Push.
Hope it may help you.
thanks

making GCM notifications configurable in applications

My question is
How to stop receiving notifications from GCM service with out using
GCMRegistar.unregistar(context).
Is there any method to stop receiving notifications.
I need this because I want to make GCM Push Notification feature configurable by the user if user sets for getting notification he will receive notification otherwise stops receiving notification with out unregistering device
Any links helps me a lot.
I do a similar thing with regards to my applications, if you get the paid version you get notifications, if you get the free version you don't get such updates.
I accomplished this by adding a field to the table where all my registration ID's are called status. When a notification push is done by my server it will only send to those registrations where the status is 'paid'.
So for your case I suggest adding the option to your application to stop receiving notifications. This method will perform a post to your server like follows:
Function updateNotificationStatus(boolean status)
{
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://yourserver/update.php");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("status", status));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new
}
Handle these posts on your server and just update the status field in you table.
Hope this helps