我在Unity调用 注册小米推送
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AVOSCloud.setDebugLogEnabled(true);
//PushService.setDefaultPushCallback(this, CallbackActivity.class);
// 订阅频道,当该频道消息到来的时候,打开对应的 Activity
// PushService.subscribe(this, "public", CallbackActivity.class);
// AVOSCloud.initialize(this, appId, appKey);
// AVInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
// @Override
// public void done(AVException e) {
// if(e ==null)
// {
// AVInstallation.getCurrentInstallation().saveInBackground();
// AVInstallation.getCurrentInstallation().put("user", AVUser.getCurrentUser());
// }
// }
// });
// AVMixPushManager.registerXiaomiPush(this, miAppid,miAppkey,profile);
// PushService.setDefaultPushCallback(this, CallbackActivity.class);
//PushService.subscribe(this, "clientId", CallbackActivity.class);
// PushService.subscribe(this, "public", CallbackActivity.class);
// PushService.subscribe(this, "clientId", CallBack1.class);
// PushService.subscribe(this, "protected", Callback2.class);
}
public void initPush(String args) {
Toast.makeText(this, "Init Push", Toast.LENGTH_SHORT).show();
String[] data = args.split(" ");
if(data== null) return ;
AVOSCloud.setDebugLogEnabled(true);
String appid = data[0];
String appkey = data[1];
AVOSCloud.initialize(getApplicationContext(), appid, appkey);
AVInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if(e ==null)
{
AVInstallation.getCurrentInstallation().saveInBackground();
AVInstallation.getCurrentInstallation().put("user", AVUser.getCurrentUser());
}
}
});
}
public void initXiaoMiPush(String args) {
String[] data = args.split(" ");
String clientId = data[2];
Toast.makeText(this, "initXiaoMiPush :" + clientId, Toast.LENGTH_SHORT).show();
if(data== null) return;
String miAppid = data[0];
String miAppkey =data[1];
AVMixPushManager.registerXiaomiPush(getApplicationContext(), miAppid,miAppkey,profile);
PushService.subscribe(this, clientId, CallBack1.class);
}
订阅 channels 时报这个错误
Unity: AndroidJavaException: java.lang.IllegalStateException: Please call AVOSCloud.initialize in main thread.