Exemple #1
0
    private void InitializeMobPush()
    {
        m_mobPush = this.GetComponentDefault <MobPush>();

        #if !UNITY_EDITOR
        m_mobPush.initPushSDK(mobAppKey, mobAppSecret);

        m_mobPush.addPushReceiver();

        m_mobPush.onNotifyCallback = OnPushNotifyHandler;
        m_mobPush.onTagsCallback   = OnPushTagsHandler;
        m_mobPush.onAliasCallback  = OnPushAliasHandler;
        m_mobPush.onRegIdCallback  = OnPushRegIdHandler;

        #if UNITY_IPHONE
        m_mobPush.setAPNsForProduction(false); // 真机调试 false , 上线 true
        var style = new CustomNotifyStyle();
        style.setType(CustomNotifyStyle.AuthorizationType.Badge | CustomNotifyStyle.AuthorizationType.Sound | CustomNotifyStyle.AuthorizationType.Alert);
        m_mobPush.setCustomNotification(style);
        #endif

        m_mobPush.getRegistrationId();

        #if UNITY_ANDROID
        m_mobPush.setClickNotificationToLaunchPage(true);
        m_mobPush.setAppForegroundHiddenNotification(true);
        #endif

        RegisterEventListener(OnPushEvent);
        #endif

        Logger.LogDetail("SDKManager:: Initialize MobPush. key: [{0}], secret: [{1}]", mobAppKey, mobAppSecret);
    }