I'm building an apache cordova messaging app (using javascript).
I'm looking for a way to have more control over notifications in my app.
Is there a way to receive a notification and build its text on the client device? I would like to create it in the user's proffered language and use the user's contacts names in the notification itself.
Also, I would like to be able to decide if to show a certain notification when it is received in the device (for example, don't show a notification for a group chat that was silenced)
Is it possible to do when the app is not open at all?
How is it handled differently from native android and iOS apps?
We are talking about push notifications right?
I don't remember the exact function names but think it's quite possible using cordova notification plugin.
So when app is in active/background, you will be able to get the notification object in your callback and decide whatever you do - show it in notification area using local notification, or show in-app alert or just ignore.
When app is closed, system handles the notification and shows in notification area(based on the notification payload APNS/GCMS sends) and when user taps on it, app is launched and a notification handler callback is called inside app.
Anyway, I think what you want to do is quite possible with native apps and cordova plugin since it exposes all of native functionalities.
Related
I have developed a game with unity and I have used 'Firebase Cloud Messaging' for push notification.
I have one problem. when I clear the received notification in tray, it seems like the message related to it is also deleted. so 'MessageReceived' is not called when I open the app.
I experienced this problem on android. Haven't tested it on ios yet.
I use firebase admin sdk for sending messages.(written with node js)
is there a way to clear notification tray without deleting the message?
thanks for any help in advance
There is some extra setup required to route notifications when the app is not running on Android.
See the Firebase docs for more information
Quote from documentation:
When the app is not running at all and a user taps on a notification, the message is not, by default, routed through FCM's built in callbacks. In this case, message payloads are received through an Intent used to start the application.
Messages received while the app is in the background have the content of their notification field used to populate the system tray notification, but that notification content will not be communicated to FCM. That is, FirebaseMessage.Notification will be a null.
Basically you need to use the custom launch activity bundled with Firebase Messaging instead of the default UnityPlayerActivity. This activity is called MessagingUnityPlayerActivity can can be found inside libmessaging_unity_player_activity.jar. You'll need to create a AndroidManifest.xml file to instruct the app to use this custom activity instead of the default Unity one.
I want my app I build with Cordova and which runs on Android and ios to check my server for some data. I then want to use this data to update the badge at the phone homescreen. For this badge I use the plugin created by Katzer https://github.com/katzer/cordova-plugin-badge.
Now I believe the best way to achieve this is to generate an Ajax call to get the data from the server. Problem is that I want to do this specifically when the user is not actually using the app, preferably about once a day. Now I have found that it is possible to achieve this in the background using various plugins that create a background mode, but this is battery intensive and won't work if the user as stopped the app.
My question is what would be the best way to update my badge without the user having to open the app?
As you said, you need to use a background service OR if you use FCM (Firebase Messaging plugin), you can set the badge number while you are sending a notification.
So the best way would be to push to the device when something happens and change the badge number at that time. Then there is no need to do any Ajax call as you can use the data that was sent with the notification.
Also welcome to S.O.
how to create a notification in the status bar on android as shown below using phonegap?
This is the example of notification that i want. notfication example
What you need its called "push notifications".
PhoneGap has some plugins for that.
plugin
sample app
tutorial
This might also be helpful:
Android notifications
Cordova local notifications plugin with instructions etc -> here you can see how the plugin is installed and used
Be warned, that using proper push notifications you'll have to register your app first - if your notifications are not only local of course.
To send push notifications, you will need to first register your app
with the push notification service (Apple APNs or Google GCM) that
corresponds to your app's platform.
I know this is old, but to anyone who is still looking, you're probably looking for this:
https://github.com/katzer/cordova-plugin-local-notifications
Push notifications allow your phone to receive on-demand notifications. What OP (and what I) was looking for was to actually put something in your notification drawer.
I have an Event management solution with web and mobile app (for both android and ios).
I am using Phonegap 2.7 for mobile app.
In my mobile app, I'm just displaying the data that is created and updated using web solution. I have a list of "Tasks" and "On-Site Tasks" in the mobile app with Date and Time and have scheduled local notifications for all the items using Phonegap's local notification plugin. The notifications are working as expected and I am recieving them on time.
But when the data is updated using web solution I have to reschedule the local notification on device and for this I have to launch the app every time I want to update the previously scheduled notifications.
My question is, Is there a way to update the local notifications whenever the data is updated on web solution without launching the app ??
I want the local notifications to be updated automatically when the data is updated from web solution.
iOS dev here, I don't know Phonegap nor do I know Android. But in general for iOS:
You need to use push notifications instead. The purpose of local notifications is to maintain them completely client-side. If the notification depends on server-side state, and you do not want to launch the app to update notifications, you need to dispatch the notifications using push.
https://en.wikipedia.org/wiki/Apple_Push_Notification_Service
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9
I would like the application to have the following capabilities:
The user would be given a timed, periodic alert (with sound) during certain times through the day upon which he/she is prompted to fill-in a quick survey. The information from the survey would then be sent off to an app server/db (this part would obviously be coded in a server-side language).
Would this be possible with HTML 5 / Javascript or would a framework such as phonegap or rhomobile have to be used?
You'll need to use a native app. There's no way for a website to do anything in the background through safari, and no way for safari to notify the user of anything if the website isn't in the foreground.
Timed periodic alerts are exactly what push notifications are for. Push notifications are only available to native apps. Push notifications will show the user an alert and let them launch the app. They also let you send a small amount of metadata into the app with the notification.
Yes You can for that you have to use phonegap. below are some reference :
http://phonegap.com/start/
http://wiki.phonegap.com/w/page/30862722/phonegap-android-eclipse-quickstart