Java Code Examples for com.xiaomi.mipush.sdk.MiPushClient#registerPush()

The following examples show how to use com.xiaomi.mipush.sdk.MiPushClient#registerPush() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushConfig.java    From FastAndroid with Apache License 2.0 6 votes vote down vote up
public static void init(@NonNull Context context) {

        if ("HuaWei".equals(android.os.Build.MANUFACTURER)) {
            HMSAgent.init(context);
            HMSAgent.connect(this, new ConnectHandler() {
                @Override
                public void onConnect(int rst) {

                }
            });
            HMSAgent.Push.getToken(new GetTokenHandler() {
                @Override
                public void onResult(int rtnCode) {

                }
            });
        } else if ("Xiaomi".equals(android.os.Build.MANUFACTURER)) {
            MiPushClient.registerPush(context, "APP_ID", "APP_KEY");
        } else if (MzSystemUtils.isBrandMeizu(context)) {
            PushManager.register(context, "APP_ID", "APP_KEY");
        }else {

        }
    }
 
Example 2
Source File: PushManager.java    From SimpleProject with MIT License 5 votes vote down vote up
public void initPush(Context context, String appId, String appKey, PushListener listener) {
	if (RomUtil.isMiui()) {
		MiPushClient.registerPush(context.getApplicationContext(), appId, appKey);
	} else if (RomUtil.isEmui()) {
		initHWPush(context.getApplicationContext());
	} else {
		JPushInterface.init(context.getApplicationContext());
	}
	mListener = listener;
}
 
Example 3
Source File: MyApplication.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    // 注册push服务,注册成功后会向DemoMessageReceiver发送广播
    // 可以从DemoMessageReceiver的onCommandResult方法中MiPushCommandMessage对象参数中获取注册信息
    if (shouldInit()) {
        MiPushClient.registerPush(this, APP_ID, APP_KEY);
    }

    // LoggerInterface newLogger = new LoggerInterface() {
    //
    // @Override
    // public void setTag(String tag) {
    // // ignore
    // }
    //
    // @Override
    // public void log(String content, Throwable t) {
    // Log.d(TAG, content, t);
    // }
    //
    // @Override
    // public void log(String content) {
    // Log.d(TAG, content);
    // }
    // };
    // Logger.setLogger(this, newLogger);
}
 
Example 4
Source File: CompatibilityDemoInit.java    From ans-android-sdk with GNU General Public License v3.0 4 votes vote down vote up
private static void initXiaoMiPush() {
    if(shouldInit()){
        MiPushClient.registerPush(mContext, XIAOMI_APP_ID, XIAOMI_APP_KEY);
    }
}
 
Example 5
Source File: MyApp.java    From star-zone-android with Apache License 2.0 4 votes vote down vote up
public static void reInitPush(Context ctx) {
    MiPushClient.registerPush(ctx.getApplicationContext(),
            MiSdkConstant.APP_ID, MiSdkConstant.APP_KEY);
}
 
Example 6
Source File: ThirdPushManager.java    From imsdk-android with MIT License 4 votes vote down vote up
@Override
public void registerPush(Context context) {
    MiPushClient.registerPush(context.getApplicationContext(), appId, appKey);
    Logger.i("注册Third推送 registerPush appId : " + appId + "  appKey : " + appKey + "  regid : " + MiPushClient.getRegId(context));
}
 
Example 7
Source File: MiPushManager.java    From imsdk-android with MIT License 4 votes vote down vote up
@Override
public void registerPush(Context context) {
    MiPushClient.registerPush(context.getApplicationContext(), appId, appKey);
    Logger.i("注册小米推送 registerPush appId : " + appId + "  appKey : " + appKey + "  regid : " + MiPushClient.getRegId(context));
}
 
Example 8
Source File: FragmentPreferences.java    From GcmForMojo with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onStop() {
    super.onStop();
    //激活推送通道
    mySettings = getSharedPreferences(PREF, Context.MODE_PRIVATE);
    String pushType=mySettings.getString("push_type","GCM");
    switch (pushType){
        case "GCM":
            deviceGcmToken = FirebaseInstanceId.getInstance().getToken();
            stopMiPush();
            stopHwPush();
            Log.e(MYTAG, "使用GCM推送");
            break;
        case "MiPush":
            if(shouldInit()) {
                MiPushClient.registerPush(this, mi_APP_ID, mi_APP_KEY);
            }
            miSettings = getSharedPreferences("mipush", Context.MODE_PRIVATE);
            stopHwPush();
            // MiPushClient.enablePush(getInstance().getApplicationContext());
            Log.e(MYTAG, "使用MiPush推送");
            break;
        case "HwPush":
            HMSAgent.init(this);
            HMSAgent.connect(this, new ConnectHandler() {
                @Override
                public void onConnect(int rst) {
                    //Log.e("HMS connect end:" + rst);
                }
            });
            HMSAgent.Push.getToken(new GetTokenHandler() {
                public void onResult(int rtnCode, TokenResult tokenResult) {
                    //Log.e("get token: end" + rtnCode);
                }
            });
            stopMiPush();
            Log.e(MYTAG, "使用HwPush推送");
            break;
        default:
            deviceGcmToken = FirebaseInstanceId.getInstance().getToken();
            stopMiPush();
            stopHwPush();
            Log.e(MYTAG, "默认DefaultGCM推送");
            break;

    }
}
 
Example 9
Source File: NotificationUtil.java    From talk-android with MIT License 4 votes vote down vote up
public static void startPush(Context context) {
    if (USE_XIAOMI) {
        MiPushClient.registerPush(context, Constant.XIAOMI_APP_ID, Constant.XIAOMI_APP_KEY);
    }
}