[英]My app does not receive Parse push notifications
I have setup my app for Parse notifications and strictly followed the instructions, but somehow I don't receive any notification. 我已经为解析通知设置了我的应用,并严格按照说明进行操作,但是不知何故我没有收到任何通知。 What is the problem here?
这里有什么问题?
Update: I just tried sending a test push notification on the Parse.com website. 更新:我只是尝试在Parse.com网站上发送测试推送通知。 That should work without subscribing to a channel (see comment)
无需订阅频道即可正常工作(请参阅评论)
My AndroidManifest.xml (only the relevant parts): 我的AndroidManifest.xml(仅相关部分):
<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.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="co.bla.bla.permission.C2D_MESSAGE" />
<uses-permission android:name="co.bla.bla.permission.C2D_MESSAGE" />
<!-- Push notification setup -->
<service android:name="com.parse.PushService" />
<receiver android:name="co.bla.bla.ParsePushReceiver"
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>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="co.bla.bla" />
</intent-filter>
</receiver>
</application>
And I have extended ParsePushBroadcastReceiver
: 而且我扩展了
ParsePushBroadcastReceiver
:
public class ParsePushReceiver extends com.parse.ParsePushBroadcastReceiver{
@Override
protected void onPushReceive(Context context, Intent intent ) {
ParseAnalytics.trackAppOpenedInBackground(intent);
String s = intent.getStringExtra("alert");
Log.d("Push received", s);
// do your stuff here
if(SugarSnapApplication.INACTIVE)
super.onPushReceive(context, intent);
}
@Override
protected void onPushOpen(Context context, Intent intent) {
// TODO Auto-generated method stub
Intent i = new Intent(context, SugarActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
@Override
protected Notification getNotification(Context context, Intent intent) {
// TODO Auto-generated method stub
return super.getNotification(context, intent);
}
@Override
protected void onPushDismiss(Context context, Intent intent) {
// TODO Auto-generated method stub
super.onPushDismiss(context, intent);
}
}
I finally found out what the problem was. 我终于发现了问题所在。 I have renamed the whole package name of my application a couple of days ago and apparently the change was not made everywhere and the applicationId in my
build.gradle
file was still the old one. 我几天前已经重命名了我的应用程序的整个程序包名称,显然更改并未在所有地方进行,并且
build.gradle
文件中的applicationId仍然是旧的。 So naturally the package name in my AndroidManifest.xml was not the same as the one saved in my Installation
class. 因此,很自然,我的AndroidManifest.xml中的软件包名称与我的
Installation
类中保存的软件包名称不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.