简体   繁体   English

使用Parse将通知从Ruby On Rails推送到Android和IOS用户

[英]Pushing notifications from Ruby On Rails to Android and IOS users using Parse

I'm building an application using Ruby On Rails. 我正在使用Ruby On Rails构建应用程序。 the app is supposed to push notifications to android and IOS user using Parse RESTfull api. 该应用程序应该使用Parse RESTfull API向Android和IOS用户推送通知。 i have tried to use parse-ruby-client but the documentation is poor and a don't get how it really works. 我曾尝试使用parse-ruby-client,但文档很差,并且无法理解它的实际工作原理。 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. 使用parse和rest api,我发现向单个用户发送通知的最简单方法是将每个用户设置为一个通道。 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: 例如,对于高级定位,如果您要查询一个类并查找将伤害报告设置为true的iOS用户,则可以使用以下命令:

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). push.type是指系统类型-iOS(ios),android(android),Windows用户(winrt或winphone)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Rails应用程序向iOS,Android,BlackBerry发送通知 - Notifications to iOS, Android, BlackBerry from a Rails app 使用无法在Android上运行的Facebook ID向特定用户发送解析推送通知 - Sending Parse push notifications to specific users using Facebook ID not working from Android 使用来自解析的API在android中发送推送通知 - Send push notifications in android using api from parse parse.com REST API使用build.phonegap Javascript推送通知Android和iOS - parse.com REST API using build.phonegap Javascript Push Notifications Android and iOS 使用 PARSE 平台的 Android 多行通知 - Android Multiline notifications using the PARSE platform 使用Parse将推送通知发送到Android设备 - Sending push notifications to Android devices using Parse 使用Sinch和Parse的Android推送通知 - Android Push Notifications Using Sinch and Parse 从Android中的解析发送推送通知 - Sending Push notifications from parse in android Android和iOS中用于推送通知活动用户的数据库设计 - Database Design For Push Notifications Active Users in Android and iOS 来自 Firebase 的应用程序(Android 或 iOS)中的提醒通知 - Reminder Notifications in App (Android or iOS) from Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM