Get user position (gps) even if app is closed - android

I'm deploying an app with Ionic framework. The app basically need to receive push notifications based on (specific) user position. Those notifications are location dependant, so I'm trying to figure out if it's possibile to retrieve current user location without ask the user to run the app.
I know that push notifications are received even if app is not running, what I'd like to do is to show notifications only if the user is in a specific area.
Thanks

I know that push notifications are received even if app is not running
That's not true. Push notifications let your application notify a user of new messages or events even when the user is not actively using your application, but application must be started and running in background.
You must perform 2 different actions:
Execute app on startup to allow it to perform actions needed.
Use GPS in background to know when device is in the desired position to notify.

Related

Retrieve push notification after coming back to online status. Firebase/Onesignal

I am using Firebase with OneSignal within an hybrid application (Android + JS with cordova app). In some cases the user may become offline and online while he is still using the application.
Note that you can't retrieve a push notification if you don't have connectivity.
So my question is, is it possible to retrieve a push notification if the another user sends a push notification while the first user is offline, and later on this first user retrieves the connectivity (As a delayed push notification)?
Thanks!
Internally, OneSignal uses Firebase Messaging Service, so the constraints should be looked for there.
Firebase has 2 types of pushes: notification messages and data messages. That matters if you want to show a notification straight when a push comes, or you'd like to do some additional processing beforehand.
Then, you can configure Firebase to store and resend every message up to 28 days. Of course, losing a network connection for some time does not prevent a message to arrive.
There is another limitation though: up to 100 messages can be stored per client. So, if there are more than a hundred, it's better to re-request the diff.
And then, when the device finally comes back to the network, you should decide if you'd like the notification to come immediately even if the app is already minimized or the device is sleeping. Here is a part about push priorities.
Finally, to be able to work with Firebase on this lower level, you may need to configure OneSignal accordingly. Here is an instruction telling how to work with the background notifications, if you need them.

What happens when Push Notification is turned off ? Will code be executed (minus UI)?

Customers can turn off push notifications at the app level. When that happens, we all know the the notification tray UI will not show up. But,
Does GCM/FCM (android) and APNS (iOS) continue to deliver notification to the customer's phone regardless ?
Specifically, on android & iOS, will I be able to execute some logic in the push event listener regardless of whether the user turned the push notifications on/off ?
In Android, when we disable push notifications, does the OS automatically unregister the app from GCM/FCM ?
Note:
I am NOT interested in background app refresh on iOS or background refresh through WorkManager on Android. I am NOT interested in iOS silent notifications or other kinds of Background Executions.
My question is specifically whether the code block is invoked (or not) when push notifications are turned off at app level (using the toggle).
I am not sure about the android, but in iOS this thing is possible.
You can do this but just keep in mind, that Background App Refresh is enable in device.
For more details, look into this link
https://www.urbanairship.com/blog/watch-list-ios-8-opt-in-changes
I hope you get your answer from above link

Ionic 3 sending notifications based on local event even if app is closed

Using the native-sensors plugin i have created a method which will notify the user when the temperature and humidity exceed a certain limit. Using the native-background mode method I was able to send these notifications when the app is in the background. But the notifications dont arrive if I kill the app.
Is there someway to use local notifications to get my needed functionality? or can I use push notifications somehow achieve this?

Cordova / Phonegap geofence app solution

I want to build a geofence app with cordova for android. The app gets the geofences from a server which are dynamically created by other users (in another app). These geofences last about 2-3 hours. When the user enters a geofence, he should get informed with a notification.
So far I have found two different ways / plugins which I can use to get the job done:
Track geolocation with BackgroundGeoLocation and send current position to server. The server saves the location and checks if the user enters an active geofence. Then it sends a push notification back to the user.
Use the Geofence plugin. But I don't know how to push new geofences from server to the app. The PushPlugin is not able to push silent informations when app is in background.
So, the first solution consumes more network traffic than the second one, but lets the server do the geofence work.
The second one communicates with the server just when it's needed, but there seems to be no plugin which does background silent data pushing. I have to write my own plugin then (unexperienced in java).
Which way would you recommend, or do you have other ideas to solve that problem easier?
You can use the pushnotification plugin, but will need to edit the GCMIntentService file for the plugin. You will also be able to determine when the silent action should be triggered based on the message information received and the current state of the app.

How to tell app was started by tapping push message notification

I have a Worklight app that receives push notifications from the server. A notification means there are new messages for the current user from other users. A user would read them by visiting a messages page within the app and then proceeding to a particular conversation page.
I would like to differentiate in the code between user intentions. The app would:
If the user started the app normally (not by tapping a new notification), present the user with the regular app home screen.
If the user started/resumed the app by tapping a notification, present the user with the messages page.
If received while the app is on foreground, only update the on-screen message count (regardless of which page is active).
The question is: is there a reliable means to differentiate between the above conditions?
In another thread, I saw a suggestion to remember the timestamp of a resume event and an onReadyToSubscribe event and assume we were asleep/inactive if notification arrives e.g. just a second after this. This would enable me to differentiate between 2 and 3.
However, 1 is not covered by this. I.e. if there have been new messages, but the user started the app normally, the app would have no means of knowing this and would think it was started by tapping a notification. This way, the user intended to see app home screen, but we transfer him to the messages page.
Is there a reliable way around this for both iOS and Android?
Worklight vesion 6.2.0.00-20140922-2259.
In a pure Native application, you can know "where from the user opened the app", meaning whether it was by tapping on a received notification or by tapping the application icon.
In a Worklight-based Hybrid application, and if using only the JavaScript API, this is not feasible because all paths arrive to the same destination which is the pushNotificationReceived function. So whether you tapped a notification or the app icon or brought the app to the foreground, the aforementioned function will be invoked.
The solution may be to base your implementation on the following Knowledge Center documentation topic: Using native and JavaScript push APIs in the same app.
This way, using a combination of native code and JS code, you could handle the scenario where a notification was received but the user decided to tap the application icon rather than the notification.
An end-to-end example would to somewhat involved to implement, but if you'll follow the code examples in the documentation topic, you should get there...

Categories

Resources