本文介绍了解析推送通知只在模拟器中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助,因为我正在使用 Parse Push Notification Android,但我的应用程序仅在模拟器中接收通知,但在真实设备中未接收.
I need help, because I am working with Parse Push Notification Android but my application just receives notifications in emulator but not receives in real devices.
在我的分析中出现注册.
In my analytics appears register.
这是我的许可和 BroadcastReceiver:
This is my permission and BroadcastReceiver:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="org.example.promociones.permission.C2D_MESSAGE" />
<uses-permission android:name="org.example.promociones.permission.C2D_MESSAGE" />
<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>
<receiver android:name="com.example.promociones.Receiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
还有我的注册码:
Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Parse.initialize(this, "SomeValue", "SomeValue");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("pruebas", new SaveCallback() {
@Override
public void done(com.parse.ParseException e) {
// TODO Auto-generated method stub
if(e!=null)
{
Log.d("com.parse.push", "La subscripcion al canal fue exitosa");
}
else
{
Log.e("com.parse.push", "Fallo la subscripcion push");
}
}
});
}
推荐答案
改用以下内容:
// inform the Parse Cloud that it is ready for notifications
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
} else {
e.printStackTrace();
}
}
});
这篇关于解析推送通知只在模拟器中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!