I am new to parse development. Basically i am developing an android and its ios app for mobile where users can send requests and invites. For this purpose a common notification platform is required. I have heard about Parse. It works fine to send push-notification to all users like Broadcast.But i need to send a notification from one user to a single user using parse. Like in my app there will be a friend list and user can send any request to any of his friends or even send him an private message.
As far as I understand (as a summary) you want to send a push notification to specific device via using Parse cloud function. In order to send a specific Push notification via Parse Cloud, you need to query Parse Installation table. Parse Installation keeps the devices that your application is installed. After finding the device ( device that you want to send push notification) you need to create Push via using the javascript API. One example from Parse tutorial is below;
var query = new Parse.Query(Parse.Installation);
query.equalTo('injuryReports', true);
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: "Willie Hayes injured by own pop fly."
}
}, {
success: function() {
// Push was successful
},
error: function(error) {
// Handle error
}
});
Hope this helps,Regards.
Related
Is it possible to set up a conversation using Dialogflow so that when you speak an application specific command to Google Assistant on an Android phone, a push notification is sent to my app without me needing to set up a web server to handle a webhook?
Can the push notification be sent directly from the in-line index.js that you enter on the Dialogflow website under the fulfillment section? If so, how?
You need to implement the firebase cloud messaging APIs in your Android App and push that message you want to your app. Please keep in mind that you need some kind of login to connect the push token of your app to your fulfillment code. Without that link you cannot send a push message. If you need more details leave a comment.
This isn't exactly what you're looking for, but you could use Nodemailer to send an email from inside your Dialogflow fulfillment. Most Android users get a push notification when they get a new email, which completes half of your goal.
var nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
var transporter = nodemailer.createTransport('smtps://user%40gmail.com:pass#smtp.gmail.com');
// setup e-mail data with unicode symbols
var mailOptions = {
from: '"Fred Foo ?" <foo#blurdybloop.com>', // sender address
to: 'bar#blurdybloop.com, baz#blurdybloop.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ?', // plaintext body
html: '<b>Hello world ?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
I want to write a little script that tells Firebase to push notification if a certain condition is met. How to send push notification from Firebase using google apps script?
I'd never tried this before, but it's actually remarkably simple.
There are two things you need to know for this:
How to send a HTTP request to Firebase Cloud Messaging to deliver a message
How to call an external HTTP API from with Apps Script
Once you have read those two pieces of documentation, the code is fairly straightforward:
function sendNotificationMessage() {
var response = UrlFetchApp.fetch('https://fcm.googleapis.com/fcm/send', {
method: 'POST',
contentType: 'application/json',
headers: {
Authorization: 'key=AAAAIM...WBRT'
},
payload: JSON.stringify({
notification: {
title: 'Hello TSR!'
},
to: 'cVR0...KhOYB'
})
});
Logger.log(response);
}
In this case:
the script sends a notification message. This type of message:
shows up automatically in the system tray when the app is not active
is not displayed when the app is active
If you want full control over what the app does when the message reaches the device, send a data message
the script send the message to a specific device, identified by its device token in the to property. You could also send to a topic, such as /topics/user_TSR. For a broader example of this, see my blog post on Sending notifications between Android devices with Firebase Database and Cloud Messaging.
the key in the Authorization header will need to match the one for your Firebase project. See Firebase messaging, where to get Server Key?
I have Android app, which is working with Azure IoT hub.
There are several tables on Azure, one of which stores credentials of registered users of my app. This table has one column called "userId" and records are unique here.
I also have node.js script which will be processing data in one of the tables and sending push notifications based on that data via GCM.
function sendPush(userId, pushText)
{
var payload = pushText;
push.gcm.send(null, payload, {
success: function(pushResponse) {
console.log("Sent push:", pushResponse, payload);
request.respond();
},
error: function (pushResponse) {
console.log("Error Sending push:", pushResponse);
}
});
}
I know that to make targeted push notification with Google Cloud Messaging, you have to get token with InstanceID class.
But can I somehow use "userId" column record to become that token to make my push notification targeted?
Generally speaking, you can leverage Tags param as tag identifier to push notifications to specified device. Refer to Sending push notifications with Azure Notification Hubs and Node.js for more.
And you can register with tags from your backend application, if your requirements are in the proper scenarios listed at https://msdn.microsoft.com/en-us/library/azure/dn743807.aspx
In backend nodejs application, you can try to use following code to register with tags:
var notificationHubService = azure.createNotificationHubService('<nb-name>', '<nb-keys>');
notificationHubService.createRegistrationId(function(err,registerId){
notificationHubService.gcm.createNativeRegistration(registerId,"identifier-tags",function(err,response){
console.log(response)
})
})
Then you can try to use the tags in send function.
Any further concern, please feel free to let me know.
Parse is shutting down and they've made their server opensource. However they do not have the extended functionality with push notifications as what used to be the case with parse.com
Can anyone help me set up push notifications on the open source version of Parse on android?
I've been through their wiki and I'm a tad bit confused about it.
If I'm not wrong, should I just add the GCM credentials to where the Parse Server is being initialized and then deploy it manually (possibly to heroku) myself and then use cURL to send notifications as per the wiki?
Or did I misunderstand the whole process and need to do something else?
Thanks in advance!
You can host your own Parser Server in a self-hosting solution or use a Parse Hosting provider like https://www.back4app.com
See all options below:
https://github.com/ParsePlatform/parse-server#parse-server-sample-application
Then you can send the push notifications using dashboard console, API or cloud code. Note that push notifications cannot be sent anymore from client. Because of security issues, Parse Server has discontinued sending push notifications direct from client. The best practice now is to create a cloud function to send the push notifications and then call it from client code. See more details below:
https://github.com/ParsePlatform/parse-server/wiki/Push#4-send-push-notifications
And here there is an example of a cloud function that can be used to send push notifications:
Parse.Cloud.define('push', function (request, response) {
// THIS METHOD NO LONGER WORKS
// Parse.Cloud.useMasterKey();
Parse.Push.send({
channels: request.params.channels,
data: request.params.data
}, {
// ADD THE `useMasterKey` TO THE OPTIONS OBJECT
useMasterKey: true,
success: function () {
response.success('Success!');
},
error: function (error) {
response.error('Error! ' + error.message);
}
});
});
You can also send the push notification throw Parse Dashboard. Parse has just announced this feature is now available:
http://blog.parse.com/announcements/push-and-config-come-to-the-parse-dashboard/
just fill the GCM field and the second field when you initialize Parse server (in the index.js or the ecosystem.json)... this will allow the server to send the Push for Android, for sending push U can use cloud code, curl or whatever. You need to use MasterKey though
I'm building an application using Ruby On Rails. the app is supposed to push notifications to android and IOS user using Parse RESTfull api. i have tried to use parse-ruby-client but the documentation is poor and a don't get how it really works. i mean how to send a notification a specific user.
In order to send a notification to a specific user you first need to have channels for each user setup or query a specific installation. With parse and the rest api the easiest way I have found to send a notification to an individual user is to setup each user as a channel. When the user initially sets up the app on their device, I take either their username or email and use that as their channel. Then when I want to send a notification to a specific user I send to that channel.
In ruby to send to a channel you would use the following substituting your channel in place of Giants
data = { :alert => "This is a notification from Parse" }
push = Parse::Push.new(data, "Giants")
push.type = "ios"
push.save
For advanced targeting, for example, if you want to query a class and find iOS users with injury reports set to true you can use the following:
data = { :alert => "This is a notification from Parse" }
push = Parse::Push.new(data)
push.type = "ios"
query = Parse::Query.new(Parse::Protocol::CLASS_INSTALLATION).eq('injuryReports', true)
push.where = query.where
push.save
The push.type refers to the system type- iOS (ios), android (android), windows user (winrt or winphone).