Android Parse Push notification device registration only one time on one device

前端 未结 7 1988
礼貌的吻别
礼貌的吻别 2020-12-04 19:07

Every one I am using the parse service for push notification in my app. but it register all time when i re-install the app in one device.Then problem is that,one device rece

相关标签:
7条回答
  • 2020-12-04 19:37

    Create new class and extend it with Application. write code in this way

      public class BBApplication extends Application {
    
    
       @Override
       public void onCreate() {
          super.onCreate();
    
           Parse.initialize(this, "app key", "client key");
              ParseInstallation.getCurrentInstallation().saveInBackground();
               ParsePush.subscribeInBackground("", new SaveCallback() {
    
                   @Override
                   public void done(com.parse.ParseException arg0) {
                    // TODO Auto-generated method stub
                         if (arg0 == null) {
                             Log.d("com.parse.push", "successfully    subscribed to the broadcast channel.");
                        }    else {
                              Log.e("com.parse.push", "failed to subscribe for push", arg0);
                        }
                }
                });
    
           ParseUser.enableAutomaticUser();
           ParseACL defaultACL = new ParseACL();
          // Optionally enable public read access.
          // defaultACL.setPublicReadAccess(true);
          ParseACL.setDefaultACL(defaultACL, true);
    }
    

    }

    Add entry in manifest file

    <application android:label="@string/app_name"
        android:name="org.cocos2dx.cpp.BBApplication"
                 android:icon="@drawable/icon">
    
    0 讨论(0)
提交回复
热议问题