解析推送通知只适用于仿真器

时间:2014-11-20 18:18:55

标签: android parse-platform push-notification

我需要帮助,因为我正在使用Parse Push Notification Android,但我的应用程序只是在模拟器中接收通知但未在实际设备中接收。

在我的分析中出现注册。

这是我的许可和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");
            }

        }
    });
}

2 个答案:

答案 0 :(得分:1)

请改用以下内容:

    // 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();

            }
        }
    });

答案 1 :(得分:0)

我有同样的问题,因为我没有检查包名

<permission
    android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />