推送通知不接收android

推送通知不接收android,第1张

概述在我的应用程序中,我尝试从服务器接收通知,但我没有收到消息.有一段时间我有这个例外(但不是所有时间): E/com.parse.ManifestInfo﹕ Cannot use GCM for push because the app manifest is missing some required declarations. Please make sure that these permis 在我的应用程序中,我尝试从服务器接收通知,但我没有收到消息.有一段时间我有这个例外(但不是所有时间):

E/com.parse.ManifestInfo﹕ Cannot use GCM for push because the app manifest is missing some required declarations. Please make sure that these permissions are declared as children of the root <manifest> element:<uses-permission androID:name="androID.permission.INTERNET" /><uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /><uses-permission androID:name="androID.permission.VIBRATE" /><uses-permission androID:name="androID.permission.WAKE_LOCK" /><uses-permission androID:name="androID.permission.GET_ACCOUNTS" /><uses-permission androID:name="com.Google.androID.c2dm.permission.RECEIVE" /><permission androID:name="com.test.parsepushnotification.permission.C2D_MESSAGE" androID:protectionLevel="signature" /><uses-permission androID:name="com.test.parsepushnotification.permission.C2D_MESSAGE" />Also,please make sure that these services and broadcast receivers are declared as children of the <application> element:<service androID:name="com.parse.PushService" /><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="com.test.parsepushnotification" /></intent-filter></receiver>E/com.parse.PushService﹕ TrIEd to use push,but this app is not configured for push due to: Push is not configured for this app because the app manifest is missing required declarations. Please add the following declarations to your app manifest to support either GCM or PPNS for push (or both). To enable GCM support,please make sure that these permissions are declared as children of the root <manifest> element:<uses-permission androID:name="androID.permission.INTERNET" /><uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /><uses-permission androID:name="androID.permission.VIBRATE" /><uses-permission androID:name="androID.permission.WAKE_LOCK" /><uses-permission androID:name="androID.permission.GET_ACCOUNTS" /><uses-permission androID:name="com.Google.androID.c2dm.permission.RECEIVE" /><permission androID:name="com.test.parsepushnotification.permission.C2D_MESSAGE" androID:protectionLevel="signature" /><uses-permission androID:name="com.test.parsepushnotification.permission.C2D_MESSAGE" />Also,please make sure that these services and broadcast receivers are declared as children of the <application> element:<service androID:name="com.parse.PushService" /><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="com.test.parsepushnotification" /></intent-filter></receiver>To enable PPNS support,please make sure that these permissions are declared as children of the root <manifest> element:<uses-permission androID:name="androID.permission.INTERNET" /><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" />Also,please make sure that these services and broadcast receivers are declared as children of the <application> element:<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>

但我并非所有时间都收到它.码:
应用:

public class TestApplication extends Application { @OverrIDe public voID onCreate() {    super.onCreate();    // Enable Local Datastore.    Parse.enableLocalDatastore(this);    Parse.initialize(this,appKey,clIEntKey);    ParsePush.subscribeInBackground("",new SaveCallback() {        @OverrIDe        public voID done(ParseException e) {            if (e == null) {                Log.d("com.parse.push","successfully subscribed to the broadcast channel.");            } else {                Log.e("com.parse.push","Failed to subscribe for push",e);            }        }    });    ParseUser.enableautomaticUser();    ParseACL defaultACL = new ParseACL();    // Optionally enable public read access.    // defaultACL.setPublicReadAccess(true);    ParseACL.setDefaultACL(defaultACL,true);}}

SaveCallback一直返回“已成功订阅广播频道”.即使我得到上面提到的例外.

表现

<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"package="com.test.parsepushnotification" > <uses-permission androID:name="androID.permission.INTERNET" /> <uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /> <uses-permission androID:name="androID.permission.VIBRATE" /> <uses-permission androID:name="androID.permission.WAKE_LOCK" /> <uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission androID:name="androID.permission.GET_ACCOUNTS" /> <uses-permission androID:name="com.Google.androID.c2dm.permission.RECEIVE" /> <permission    androID:name="com.test.parsepushnotification.permission.C2D_MESSAGE"    androID:protectionLevel="signature" /> <uses-permission androID:name="com.test.parsepushnotification.permission.C2D_MESSAGE" /> <application    androID:allowBackup="true"    androID:icon="@drawable/ic_launcher"    androID:label="@string/app_name"    androID:name=".TestApplication"    androID:theme="@style/Apptheme" >    <activity        androID:name=".MainActivity"        androID:label="@string/app_name" >        <intent-filter>            <action androID:name="androID.intent.action.MAIN" />            <category androID:name="androID.intent.category.LAUNCHER" />        </intent-filter>    </activity>    <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.test.parsepushnotification.PushReceiver"        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="com.test.parsepushnotification" />        </intent-filter>    </receiver>    <receiver androID:name="com.parse.ParsePushbroadcastReceiver"        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>    <Meta-data androID:name="com.parse.push.notification_icon" androID:resource="@drawable/ic_launcher"/> </application></manifest>

MainActivity.java

public class MainActivity extends Activity{  @OverrIDe  protected voID onCreate(Bundle savedInstanceState) {      ParseAnalytics.trackAppOpenedInBackground(getIntent());      super.onCreate(savedInstanceState);      setContentVIEw(R.layout.activit);  }}

PushReceiver.java

public class PushReceiver extends broadcastReceiver {  private static final String TAG = "PushReceiver";  @OverrIDe  public voID onReceive(Context context,Intent intent) {      Log.d(TAG,"Message accept");     showNotification();  }}

在此先感谢您的帮助.

解决方法 从有问题的清单,
< receiver androID:name =“com.test.parsepushnotification.PushReceiver”androID:permission =“com.Google.androID.c2dm.permission.SEND”>,
在 Quick Start | Parse被提及为
 < receiver androID:name =“com.parse.GcmbroadcastReceiver”androID:permission =“com.Google.androID.c2dm.permission.SEND”>,
 更改的包名称可能导致Parse方面的识别问题.

感谢您告诉我们它的工作原理.

总结

以上是内存溢出为你收集整理的推送通知不接收android全部内容,希望文章能够帮你解决推送通知不接收android所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1125383.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存