且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解析推送通知只是工作在模拟器

更新时间:2023-02-26 21:52:10

使用以下代替:

  //通知解析云计算,这是准备的通知
    PushService.setDefaultPushCallback(这一点,MainActivity.class);
    ParseInstallation.getCurrentInstallation()。saveInBackground(新SaveCallback(){
        @覆盖
        公共无效完成(ParseException的E){
            如果(E == NULL){

            } 其他 {
                e.printStackTrace();

            }
        }
    });
 

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.

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>

And my code of registration:

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");
            }

        }
    });
}

use the following instead:

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

            }
        }
    });