示例#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);
    }
示例#2
0
    private void MobPushInit()
    {
        // IPHONE 要想收到 APNs 和本地通知,必须先要 setCustom (only ios)
#if UNITY_IPHONE
        mobPush = gameObject.GetOrCreateComponent <MobPush>();
        mobPush.onNotifyCallback = OnNitifyHandler;
        // 真机调试 false , 上线 true
        mobPush.setAPNsForProduction(false);

        CustomNotifyStyle style = new CustomNotifyStyle();
        style.setType(CustomNotifyStyle.AuthorizationType.Badge | CustomNotifyStyle.AuthorizationType.Sound | CustomNotifyStyle.AuthorizationType.Alert);
        mobPush.setCustomNotification(style);
#endif
    }
示例#3
0
    void Start()
    {
        mobPush = gameObject.GetComponent <MobPush>();
        mobPush.onNotifyCallback  = OnNitifyHandler;
        mobPush.onTagsCallback    = OnTagsHandler;
        mobPush.onAliasCallback   = OnAliasHandler;
        mobPush.onDemoReqCallback = OnDemoReqHandler;
        mobPush.onRegIdCallback   = OnRegIdHandler;

        // IPHONE 要想收到 APNs 和本地通知,必须先要 setCustom (only ios)
                #if UNITY_IPHONE
        // 真机调试 false , 上线 true
        mobPush.setAPNsForProduction(false);

        CustomNotifyStyle style = new CustomNotifyStyle();
        style.setType(CustomNotifyStyle.AuthorizationType.Badge | CustomNotifyStyle.AuthorizationType.Sound | CustomNotifyStyle.AuthorizationType.Alert);
        mobPush.setCustomNotification(style);
                #endif
    }