Parse: send push notifications from app - android

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/

Related

How do I receive push notifications of new Outlook emails to an Android device?

I'm making an Android app in which I want user to sign in to their Outlook account and receive push notifications to the app from the Microsoft Graph API when an email is received in their inbox. How can I do this?
I can subscribe to inbox changes using a HTTP subscription request (as specified here https://learn.microsoft.com/en-us/graph/webhooks?view=graph-rest-1.0), with something like:
POST https://graph.microsoft.com/v1.0/subscriptions
Content-Type: application/json
{
"changeType": "updated",
"notificationUrl":
"https://webhook.azurewebsites.net/notificationClient",
"resource": "/me/mailfolders('inbox')/messages",
"expirationDateTime": "2016-03-20T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
In this request I need to specify a "notificationUrl" where notification updates are sent to - how can I set this up? Is there functionality for this on Azure?
From there I believe I can use the instructions here to send push notifications to the Android device https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-android-push-notification-google-fcm-get-started.
This involves setting up a notification hub on Azure which connects to Firebase, which then sends notifications the app. Is this the best/only way to do this?
Any help much appreciated!
The notificationUrl can be the webhook url of the azure function app. https://azure.microsoft.com/en-us/resources/videos/create-a-web-hook-or-api-azure-function/.
Therefore, you can use azure function to invoke Firebase API to send notifications.
Please see https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-notification-hubs#packages---functions-1x and https://firebase.google.com/docs/cloud-messaging/migrate-v1.
Besides, I would recommend you to use azure logic app. It has built in connector to use when a message arrives your inbox.
Take a look here https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-office365-outlook.

Not able to send Parse push on Android

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);

Send App to App push notification in android using parse.com

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();

How to send a push Notification (Parse) When a user publish a message Android

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

sending push notification to multiple users using Parse in 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

Categories

Resources