[英]Parse Push notifications on Android
I am making an app that will use the Parse.com Push notifications, however it is not working like the guide shows. 我正在创建一个将使用Parse.com推送通知的应用程序,但它不像指南显示那样工作。
The issue is, i have set up the Parse push activity fine, registered the new installation, and am able to see which channels a user is subscribed to. 问题是,我已经设置了Parse推送活动,注册了新安装,并且能够看到用户订阅了哪些频道。 I am able to receive the Push notification from parse, but unable to send from my app.
我能够从解析中收到推送通知,但无法从我的应用程序发送。
There are no errors following in logcat, and parse records that a push was sent, but shows that there are "no subscribers" to the channel. 在logcat中没有错误,并解析了发送推送的记录,但显示该通道没有“订阅者”。
In my onCreate: 在我的onCreate中:
Parse.initialize(MainActivity.this, "***", "***");
PushService.setDefaultPushCallback(this, MainActivity.class);
PushService.subscribe(this, "Everyone", MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
The Push code: 推送代码:
ParsePush push = new ParsePush();
push.setChannel("Everyone");
push.setMessage("Hey!");
push.sendInBackground();
The manifest: 清单:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application>
....
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
There are no errors in logcat, everything seems to be sent smoothly, but in parse i get the following messages: 在logcat中没有错误,一切似乎都顺利发送,但在解析时我得到以下消息:
My Push 我的推动
You sent this push notification to 0 recipients.
Targeting : channels includes "Everyone"
Sending date : November 28th, 2013 at 9:40 AM
Expiration : None
Full target : { "channels": { "$in": [ "Everyone" ] } }
Full data : {"alert"=>"Hey!"}
The only changes i can see from the push that i send vs the Push that parse.com sends is the "Full data" field 我发送的推送与parse.com发送的推送的唯一变化是“完整数据”字段
Parse Push 解推
Targeting : channels includes "Everyone"
deviceType is "android"
Sending date : November 28th, 2013 at 9:21 AM
Expiration : None
Full target : { "channels": { "$in": [ "Everyone" ] }, "deviceType": "android" }
**Full data : { "alert": "hi" }**
Thanks in advance for any help / ideas 提前感谢任何帮助/想法
You should turn on push notification from parse setting on the website parse.com 您应该从网站parse.com上的解析设置打开推送通知
App -> Settings -> Push Notifications -> Client push enabled (should be on) 应用程序 - >设置 - >推送通知 - >启用客户端推送(应该打开)
In my case, I defined a packageName
in the AndroidManifest.xml
different of the build.gradle
... it took 3 hours to realize the error. 在我的例子中,我在
AndroidManifest.xml
定义了一个与build.gradle
不同的packageName
...它花了3个小时来实现错误。 Maybe it could help :) 也许它可以帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.