sending push notification to multiple users using Parse in android - android

I want to send push notification to multiple users using parse backend. can i target a friends with Facebook id without creating channel?(in my app i integrated Facebook)
if not possible send me code with creating channel

Parse has different possibilities depending on which kind of account you have. I assume you have the free one so you CANNOT send push notifications to specific or multiple users with this kind of account. BUT you can send them through the website controller to just iOS or Android users which is the only option you have with the free account.
I actually encourage you to use channels to do so. I assume you already have the correct initializations as explained in the parse website (https://parse.com/docs/android_guide)
// Create our Installation query
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("channels", "Giants"); // Set the channel
pushQuery.whereEqualTo("scores", true);
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery);
push.setMessage("Giants scored against the A's! It's now 2-2.");
push.sendInBackground();
I ultimately reccomend you to read this guide: https://parse.com/docs/push_guide#sending-queries/Android

Related

One Signal Push Notification?

I have made movie review app on android.Users create an account with firebase authentication and review movies and rate them.Admin of app can add new movies.
My question is how can I(admin) send a notification to all users (of firebase) whenever I added a new movie?And I want to use one signal push notification.
Please Help me.
Using Tags its possible to send the notification to all users.
1.Primarily you have create a channel eg: allusers from mobile end need to register
JSONObject tags = new JSONObject();
tags.put("allusers", "1");
OneSignal.sendTags(tags);
2.From server end who are all registered in the tag allusers=1 ..Notification will send to all the users
Sending Push from serverside
https://documentation.onesignal.com/reference#create-notification

I want to send push notification from one android device to another using my application by Parse.com.

I want to make an app where one user can ask for help and all other using this app will get that notification. I am using Parse.com for this as server. i am totally new to this please help me.I got registered my device by key etc. now i can send push notification from parse.com to my device.
but don't know how to make this on my device to send this to other devices?
You can create subscribe devices to different unique channel names, then you can send notification containing required payload to the device using the channel to which other device is subscribed.
//subscribing to channel
ParsePush.subscribeInBackground("Channel_Name");
//getting installed devices
ParseQuery pushQuery = ParseInstallation.getQuery();
//query for getting devices with channel name
pushQuery.whereEqualTo("channels", "Channel_Name");
ParsePush push = new ParsePush();
push.setQuery(pushQuery);
push.setMessage("Your message payload");
push.sendInBackground();
You can subscribe multiple devices to same channel, but in this case when notification is send , it will be sent to all devices subscribed to a particular channel.
For more info: https://parse.com/docs/android/guide#push-notifications

Customise Parse push notification - Android

I am new to use Parse push notifications for Android. I have successfully integrated parse push notification to my project and tested. It works fine, but I have a few questions related to this push notification service, which I am not able to find in the Parse documentation.
How do I customise the push notification's sound?
How do I send a push notification from the device itself, without using the parse console?
What is the unique Id that I must save in order to perform the above?
Thanks in advance.
How do I customise the push notification's sound?
By default when a push notification is received the BroadcastReceiver specified in AndroidManifest.xml with intentfilter specified <action android:name="com.parse.push.intent.RECEIVE" /> is called.
Parse.com provides a BroadCastReceiver com.parse.ParsePushBroadcastReceiver which just sounds the default notification sound of the device. It does not have code for a specific notification sound, if you want to change the notification sound for push by parse you would have to implement a new BroadCastReceiver with the intentfilter specified above and have the below code for a custom sound(its only a partial code for demonstration):
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
builder.setSound(alarmSound);
How do I send a push notification from the device itself, without
using the parse console?
Push notification can be sent from a device to another device or from console to devices. Every Parse application installed on a device registered for push notifications has an associated Installation object. The Installation object is where you store all the data needed to target push notifications. Now there would be many app users and you would want to target a specific user, for eg an app collects username at the first installation of the app and sets it in Installation object shown as below:
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("userName", "ranjith"); //mobile 1
installation.saveInBackground();
Now to send notification to the username "ranjith" you would need to create a ParseQuery object with the condition -username=ranjith shown as below, this would send a push notification to username "ranjith".
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
ParseQuery pushQuery = ParseInstallation.getQuery();//mobile2
pushQuery.whereEqualTo("userName", "ranjith");
ParsePush push = new ParsePush();
push.setQuery(pushQuery); // Set our Installation query
push.setMessage("My first notification");
What is the unique Id that I must save in order to perform the above?
These are the 2 unique ids present within parse installation object and these are generated by parse and you would not need to worry about it, to target a specific user you can add a unique id/username field in Installation object as specified above,
installationId: Unique Id for the device used by Parse (readonly).
appIdentifier: A unique identifier for this installation's client
application. This parameter is not supported in Android.(readonly)

Sending Push notifications from parse in android

I have been trying to send a simple push notification from one device to the other using parse and I am with no luck.
Lets say I have a twitter clone that has follow/unfollow feature, if for instance User-A begins to follow User-A all I am trying to do is notify User-A that he is now being followed by User-B
This is the simple code that I am running
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("userId", "0VZF1l5qyA");
// Notification for Android users
ParsePush androidPush = new ParsePush();
androidPush.setMessage("Your suitcase has been filled with tiny robots!");
androidPush.setQuery(query);
androidPush.sendInBackground();
Just to even make sure that it works, I hard coded the value in but still nothing is being sent. And it also not like the user that I am trying to target is not on the server.
This how my installation table looks
I think something as simple as this should just work. Or maybe I missing how push notifications work.
By the way I am able to send push notifications from the Parse web app.
FYI - I have read the entire section of this and still not getting it to work.
Addendum: I have this block of code in my main activity and modified my manifest to look like this.
// Associate the device with a user
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("user",ParseUser.getCurrentUser());
installation.put("userId",ParseUser.getCurrentUser().getObjectId());
installation.saveInBackground();
By default clients are not allowed to push notification. You MUST do the following else your app wont work!!

Parse: send push notifications from app

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/

Categories

Resources