Sending Push notification from client - Worklight - ibm-mobilefirst

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!

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.

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.

Related

Prevent device notification client side with React Native Firebase when a FCM notification arrives (based on user preferences)

I'd like to know if there any a way to prevent the device display a notification when a FCM message with a notification arrives, in case the user has decided to mute notifications and only have them arrive silently (making them act as data only messages, but being notification messages). I imagine like, in the handler/callback call a method to prevent the device notification and do extra processing afterwards.
I know I can use data only messages, but that approach would be harder since I must use multiple topics or token lists and somewhat more backend logic to achieve that.
Thanks
If the message contains a notification property, it is automatically handled by the OS when the app is not active. There is nothing you can do to prevent that.
As you said: if the message only contains a data property, it is always passed to your code for handling, and you can decide what to do with it. So that's the way to go if you want full client-side control over whether a notification is displayed for a message.

Showing shell Toast notification on receiving message

I am trying to make a chat app using XMPP protocol. The app is working fine except it doesn't show message notification when the app is in background. In Android I have used a Service for this purpose, however in Windows Phone I couldn't find anything similar to this.
I am trying Background Tasks for this, but as far as I have understood, they're made to run on prespecified trigger and I cannot add any custom trigger to it. In Android I have put my socket connection and parsing message calls in the service itself so that they can run on background too and the socket doesn't get closed even when the app is stopped.
So my question is, is there any similar way to do it in Windows Phone 8.1 (WinRT, not silverlight) or if Background Task is the only option, can you suggest a way to implement the notification functionality. I don't need the exact code, I just need a push to the right direction.
First: You cannot run a network connection in background.
Suggested way is using PushNotifications:
Either directly with a Toast Notification
Or with a PushTrigger to handle a Raw Notification, work out what to do
with it (who was it from, prepare data, etc.) and then create a ShellToast from it. Adds flexibility and improves user experience, but is quite complex.
Known downside: You have to use a server.
Only workarounds: Background-Tasks that checks for new messages about every 30 Minutes.

Can wifi / geo triggers be invoked even if the Worklight app is not running, including not in the background?

In Android, an app which is not currently running can be notified when certain event happens (like wifi scan results available, boot process completed) through Broadcast Receivers mechanism. Is this possible in anyway so that the wifi/geo triggers can be invoked even if the Worklight app is not running, including not running in the background?
Regarding wifi/connectivity changes notifying your app, that looks possible since it is a standard system event. It would likely take custom native code since you'd need to implement a broadcast receiver. And you'd need to register your receiver in your app's AndroidManifest.xml file. Take a look at http://developer.android.com/reference/android/net/ConnectivityManager.html and http://www.grokkingandroid.com/android-getting-notified-of-connectivity-changes/
Regarding geolocation triggers, it is unclear what sort of triggers you are looking for. This is all I see in the Android docs: http://developer.android.com/reference/android/location/GpsStatus.html and the standard broadcast actions at http://developer.android.com/reference/android/content/Intent.html#constants
If you are looking for something like geofencing, it would take application logic to determine when to fire events, so that means an app or service needs to be running. So although your broadcast receiver's onReceive() method can get called upon a geo event, who is going to fire that event?
Having the triggers activate when the application is not running at all (not even in background) isn't supported through the Worklight APIs.
You could try and use Worklight Android Native SDK together with cmarcelk's suggestions. Or you could use the Worklight Android triggers within a native service, together with the Broadcast Receivers mechanism so that it will run automatically on boot. You could then use an Intent to open the application from the trigger callback.

How to create a scheduled GET request and send Notifications when the app is in background?

I have a Web-Service application, i need to send scheduled GET methods to my server and if a change has happened with my incoming data i have to inform my user about the changes. When my app is in the foreground(in min thread) i fetch some data and pıpulate my tableview, my problem is, i can't realize how to create a scheduled method to the same data source(mean server) and if a new thing has been added, either my app is on bacground or not, inform user(alert) about the changes. Can anyone please share any idea-link.. Thanks in advance
This is exactly what push notifications were designed for, and are, technically the best way to solve the problem.
It does mean the task of 'checking' for new data is shifted to your server but the user is better suited as a push notification will happen, even if your app is not running.
I recommend using a system like Urban Airship.

WCF server controlling client (windows forms)

I'm building an application, it's easy and what I want to do is the following. I want a brainless client and all the work should be done on the server. So I want a way to change windows forms in my server application and not on the client itself.
So when I have an application like blackjack the user presses hit then the hit function on the server get called, he will calculate everything, send the result back to the client and then the client updates it buttons and GUI (like displaying cards, and so on).
Now how do you do this in WCF? I know how to call remote function but I can't get the windows forms part to work (can I add this in the contract, and how?)
Thanks!
Your client should handle all of its own UI. Your service shouldn't have anything to do with the UI.
Instead of having the service handle the UI, just have it send messages back to the client and let the client figure out which UI elements to show or not based on the messages.
So, when the server calculates some result, like BLACKJACK!, it'll send a message indicating that back to the client which will then show the proper UI elements.
Make sense?