Phonegap(cordova) Pushplugin Silent Notification - Android - android

I am working on a chat application using phonegap for android, which is already running over web. I am sending messages through pushnotification and everything is working fine and notification is coming in status bar with default device sound setting. Now I want to sync some data from server without notifying user, means I need a notification that should just tell me that there is some new data on server to sync, without having status bar notification. I searched over web but couldn't found anything which can help me.
Any help would be great..
Thanks
Jaya

You could modify the plugin to not create a notification if a certain variable is set.
If you are using PushPlugin:
A notification is created only if you send message in the payload. But you will receive the payload in your application's callback. You can use this effectively to communicate with your application with having to implement anything additional.

Related

Android FCM Notification Not Popping Up

In my Android app, the Push Notification Firebase Cloud Messaging is only received on the device when the user is not in the app at the time of sending - The message is received, but not displayed. I made a console.writeline to log if the message was received, and it was, but no sound was made and the notification didn't pop up.
Some background:
I am testing on an emulator
I am using the FirebasePushNotification Plugin (as it is a Xamarin.Forms project and I want to be able to do cross-platform setup
I have downloaded GoogleServicesJSON, set build action, etc.
I think you are sending the Data messages,When using this type of message you are the one providing the UI and handling when push notification is received on an Android device.
So you should define and create your notification yourself in the receive callback.

Mass push notification sending in some intervals

I am trying to figure out how Facebook / Twitter sends push notifications like "You have 20 new followers"I don't know how to call it but i want to learn the underlying algorithm of this in Android. Please help, Thanks !
On Android you can execute your code before actually showing a push notification. They could simply send a push notification to all devices with an identifier, then the app can make a request to the server and get the needed information in order to show the push notification.
They can also send one push notification per device, as they can associate the push notification key with the user login, and the server would fire a push notification every time there is an event that demands a push notification.
But there are also other ways of doing this, for example, they can, for example run locally in background and create a local notification when the app decides it is necessary.

Parse Android Push Do not display notification

I'm using Parse to send push messages to my app. In some cases I want to show a notification however in some cases I don't. For example when data should be updated I intend to send a notification to all devices so that way they don't have to poll. This should not show any notification.
Parse's GcmBroadcastReceiver seems to always generate a notification without any way of turning that off.
I'm also curious of how to stop Parse from auto-creating a notification because at some point I'm going to want to work with more complex notifications, which Parse doesn't support.
I've tried creating my own GcmBroadcastReceiver however when I did that I didn't receive anything. Maybe I rigged it wrong? Other than that how can I stop Parse SDK from auto-generating a notification?
Omit alert and title from your push notification and the parse.com android SDK will not create a notification.

How to get push notification on/off status programmatically to send it to my webserver?

I have implemented push notification in my app sucessfully using GCM.
I Am using my dotnet webserver to send push message to my app vai GCM Server.
I have stored GCM Registered Id in database on my server.
Now I want to check that if user has manually disable/off the notification for my app (by going through setting), so that i can send request to my webserver that not to send push message to that device by removing GCM ID from database(unregistering).
I know push messages are delivered to my app and are ignored if notification is off but my problem is that my app is going to be used by more 100000 users/devices and if only few of them are using notification on, then there is unnecessary traffic of sending push messages over 100000 devices/users.
So is there any way to know the status of the notification on/off programmatically so that i can send request to deregister the app on my web server?
I have googled and found that there is no way to find it out, so is any one has other solution for my scenario.
Please help me on this as i am stuck on this from last couple of days.
Thanks in advance,
Ketan Bhangale
Store user status in SharedPreference and check status while displaying notification.
same status you can store on your server and sort list of sender with status.
The ability to disable an app’s notifications is only for devices currently running Android 4.1+ Jelly Bean. Also there seems to be no documented way to know the value for notification flag(check box) in default application settings.
Simply you need to maintain that manually. Say first create a web service for update "notification setting" . The app will send the value for notification say "true" or "false" as chooses by user fro our app settings menu.
Now at server side store that value for notification_flag corresponding to that user in your db.
Before sending the notification to the user on your desired even(as per app requirement when to send notification) , check first the value of the flag before firing the send notification msg on the device id for that user.
Also finally to be more reliable at app end too , check the value for that flag before showing the notification in the app when the message arrived.

Air iOS/Android push notification remember when app launches

I have an app built for iOS and Android which has push notifications. Everything is working great however I was wondering if there is a way to store the data of the push notification in the app so that when users launch the app after receiving a notification I can show them the message again?
Basically I allow users to share information and/or chat amongst their friends. If they receive a notification when the app is in the background it comes through as a normal push message but when they launch the app I would like to direct them to the chat feature to see the message again.
I am storing the messages sent in a remote DB but seeing as they have already received the payload it doesn't make much sense for the app to call the remote DB to retrieve the same message.
I am using Distriqt's extensions in AS3 and Air 3.5.
Cheers
I asked Distriqt's support for the same thing a few weeks ago and they explained that there is no way to get the information of the push notification message while the app is closed so they suggested this :
- when the user opens the app, you call your server to check if they haven't missed anything, and get the data from there. If there has been a push, you display the push message as if it was received with the app in the foreground.
It's a bit tricky and not very satisfying but it works.. As long as the user follows the path.
If your user receives the push and chooses not to open your app, he will still get the push message in your app next time he opens it.
I was having trouble figuring this out too but I found a solution! Basically if a user launches an app (not running in the background) by way of a notification it comes through in the Invoke event, not the usual Notification event. So do this:
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, invoked);
private function invoked(evt:InvokeEvent):void
{
if (evt.reason == InvokeEventReason.NOTIFICATION)
{
var payload:Object = Object(evt.arguments[0]);
// do stuff
}
}
That's pretty much it. There's more detail in this blog post here: http://blogs.adobe.com/airodynamics/2012/05/29/push-notifications-support-in-ios/
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, invoked);
doesn't work correctly for Android push notification. Android starts with InvokeEventReason.standard all the time, so we cant receive message. It works only for iOS.

Categories

Resources