I have integrated the push notifications by Parse.
The notifications looks properly integrated as when I send them from the web end, I am able to receive them.
Now when I send the same push from Android nothing happens, here is a small code for the same:
ParsePush push = new ParsePush();
push.setMessage("Test");
push.sendInBackground(new SendCallback(){
public void done(ParseException pe){
Log.i(pe==null?"No exception":"Exception");
}
});
Since I am able to receive push from web it's confirmed they are well integrated.
Then what's the issue?
Assuming that you're using channels to send your push notifications, you just forgot to set the channel for your push notification. You just need to add:
push.setChannel(YOUR_CHANNEL_NAME);
Related
FCM message can be pushed from console and using api
from console (https://console.firebase.google.com)
using api (https://fcm.googleapis.com/fcm/send)
In both case when app is in foreground, message is received in service that extends FirebaseMessagingService, in onMessageReceived we can filter requests by custom param in bundle, but when app is in background and message is sent from console, receiver is not called, and the push message is somehow added.
Is possible to handle this request?
When app is in background and you suppose to fire notification via console at that time notification will come in notification tray rather than going to your service.
That will mentioned in guidelines.
https://firebase.google.com/docs/cloud-messaging/android/receive
So if you want to still handle notifications then, you have to set proper payload for same. So that whenever user click on notification then it will react accordingly.
For disabling notification try following,
FirebaseInstanceId.getInstance().deleteInstanceId();
Firebase Cloud Messaging support two types of messages:
Notification messages, sometimes thought of as "display messages." [When the app is not active], these are handled by the FCM SDK automatically.
Data messages, which are handled by the client app.
The Firebase console always sends notification messages, which are (when the app is not active) handled by the system. There is no way to intercept these messages in that case.
If you want to always receive the message in your application code, you should use a data message, which can only be sent using the API.
Yes, it is possible to handle messages when app is in foreground/background. In both cases you can handle it by implementing onMessageReceived. The only difference is, You have to put data in your JSON Message. Here you can find more.
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> data = remoteMessage.getData();
String myKey = data.get("myKey");
}
I have been trying to send push notifications to a Phonegap app deployed on iOS and Android. iOS works fine, but Android doesn't work when I send push notifications from any of the dev consoles from PubNub, Parse and Amazon SNS.
I did verify that I can send notifications if I use the GCM API, so I am using the correct Sender ID, API key and the device token.
I don't see any errors on PubNub console. On Parse dashboard I see that the push notifications have been sent. No error on Amazon SNS. Yet, no push notifications on the device.
I am out of ideas. Thanks in advance for any helpful advice.
With help from PubNub, figured out what the issue was. The sample on PubNub has the following format
{"pn_gcm": {
"data" : {
"GCMSays" : "hi" }
}
}
But the required format was
{"pn_gcm": {
"data" : {
"message" : "hi" }
}
}
After confirming using PubNub console, I updated my JSON object in the code and it all worked like a charm.
With Parse console, I tried to create a JSON object with similar format, but it didn't work. Haven't tried Amazon SNS.
This tutorial illustrates how to configure Android GCM with PubNub: http://www.pubnub.com/docs/java/android/tutorial/google-push-notification.html
[Parse developer] Parse doesn't provide 1st party support for PhoneGap; their product just works with the JS SDK, which doesn't have native Push support. I describe what is necessary to get Parse to recognize your device for push in an arbitrary language in a previous question. You may however be receiving the push but not creating a notification.
In Android (unlike iOS, WinRT, or WinPhone), push doesn't necessarily imply "notification." The native android SDK from Parse creates this automatically for you. You'll need to create your own BroadcastReceiver and wire it to handle the intents that the Play Store app is sending for pushes. You can find these in our Android Push Tutorial. In your BroadcastReceiver, you'll want to create and register your own Notification object when receiving a push.
For Firebase Cloud Messaging, I had to use this structure to receive a tray notification:
"pn_gcm": {
"notification": {
"title": push_title,
"text": push_message
}
},
I have created a application in android using parse.com to implement push notification. I get notification come successfully from server to my device when I triggers the push button in parse.com
Now My question is that how can I send the same notification from one device to another using parse.com
ParsePush push = new ParsePush();
push.setChannel("Giants");
push.setMessage("The Giants just scored! It's now 2-2 against the Mets.");
push.sendInBackground();
I'm new to Android, I'm developing an application which is a little bit similar to WhatsApp, I have different users, and I want when a User send a message, other users should receive a Push Notification.
So when a user add a new message, when a value will be inserted to the class, all the users should receive Push notifications.
I know how to send a push notification from the console, but I want push notifications to be sent automatically.
Thanks
You can send push notifications with parse by using channels whereby each user subscribes to a set of channels and you can send pushes to particular channels.
OR
You can use advanced targeting in which you use the installation class to select the devices.
ParseQuery<ParseInstallation> pq = ParseInstallation.getQuery();
pq.whereEqualTo("area", message3);
pq.whereEqualTo("group", message2);
pq.whereNotEqualTo("key", value);
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pq); // Set our Installation query
push.setMessage("New Message");
push.sendInBackground();
Intent in = new Intent(Post.this,Notifications.class);
progress.dismiss();
startActivity(in);
OR
You can use cloud code to receive the data sent by the user and send push notifications to relevant devices
I am wondering how to send a parse push notification directly from my android app to evryone else using my app. Is it possible to do this?
If you want to use Parse, Go to parse dashboard and there you will see the settings for push where you will find this client-side push setting.
ParsePush push = new ParsePush();
String message = "Client message" + Integer.toString(i++);
push.setChannel("Channel Name");
push.setMessage(message);
push.sendInBackground();
You can send push notification from client side as metioned by #Dmitry
However parse strongly recommend not to use that feature [Security vulnerabilites issues]
Parse developers recommend "Cloud code" to send push notification to other users from your app.
Please read this
http://blog.parse.com/learn/engineering/the-dangerous-world-of-client-push/