[英]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.