0

I know that push notifications are being sent from a backend server. Is it possible to send notification from client itself? My application goes like this: It acquires its position using Location services API. once it enters a specific circle, the trigger calls a callback function. What i want to do is to use the callback function to push a notification to the device. Is there any way to do this?

Thank you very much in advance!

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
AWSSET
  • 397
  • 1
  • 4
  • 12
  • No easy way to do it. When you enter a specific zone, use the Location API's Trigger to send an adapter request to your backend, which will tell it to send a push. – Idan Adar Sep 02 '14 at 01:14
  • Hi, I've been researching but still cannot find the answer, can you show me the detailed steps on how to do this. I'm sorry.. i'm new to worklight. – AWSSET Sep 02 '14 at 11:28

2 Answers2

1

If you just want a notification when the app is active in the background, you can use local notifications: https://github.com/katzer/cordova-plugin-local-notifications. The plug-in Javascript has to be modified somewhat to work with a Worklight app, but with some simple modifications it works great, and allows your app running in the background to raise a notification without going through the server side round trip involved when using push.

That said, I implemented an app that did exactly what you are looking for (in my case, I needed some server side processing to figure out what the text of the push message should be) The geo-fence callback called an adapter, providing it with event details and the device ID. The adapter determined what message to send, and used unicast push to send it back to the device.

David Dhuyveter
  • 1,416
  • 9
  • 17
0

You can invoke a procedure in the client side. I tried to invoke in the client side with httpAdapter and its working.

If the notification doesn't need to come from the server, you can also create a service that will run in the background and show a dialogbox once it enters the geofence.

black1011
  • 284
  • 3
  • 18
  • Hi, I tried this. the pushnotificationreceived() function declared in registerEventSourceCallback was called however no push notification was actually received. – AWSSET Sep 03 '14 at 02:48