コード例 #1
0
 public KiiPushMessage GetKiiPushMessage(KiiPushMessageData data, APNSSetting apns, GCMSetting gcm)
 {
     return(KiiPushMessage.BuildWith(data)
            .EnableAPNS(EnableAPNS)
            .EnableGCM(EnableGCM)
            .SendAppID(SendAppID)
            .SendObjectScope(SendObjectScope)
            .SendOrigin(SendOrigin)
            .SendSender(SendSender)
            .SendToDevelopment(SendToDevelopment)
            .SendTopicId(SendTopicId)
            .SendToProduction(SendToProduction)
            .SendWhen(SendWhen)
            .WithAPNSMessage(apns.GetAPNSMessage())
            .WithGCMMessage(gcm.GetGCMMessage())
            .Build());
 }
コード例 #2
0
    protected override void ProcessInitialization()
    {
        Debug.Log("#####Main.Start");
        kiiPushPlugin = GameObject.Find("KiiPushPlugin").GetComponent <KiiPushPlugin>();

        string lastMessage = kiiPushPlugin.GetLastMessage();

        if (lastMessage != null)
        {
            //Check if the last message id was triggered from notification.
            ReceivedMessage parsedLastMessage = ReceivedMessage.Parse(lastMessage);

            string BackgroundMsg = "";
            if (parsedLastMessage.GetString("MsgBody") != null)
            {
                //Android
                BackgroundMsg = parsedLastMessage.GetString("MsgBody");
            }
            else if (parsedLastMessage.GetString("body") != null)
            {
                //iOS
                BackgroundMsg = parsedLastMessage.GetString("body");
            }
            string parsedLastMessageId = BackgroundMsg;

            _lastBackgroundPushMessageIdTriggered = parsedLastMessageId;
            if (_onBackgroundPushMessageReceived != null)
            {
                _onBackgroundPushMessageReceived(parsedLastMessage);
            }
            else
            {
                Debug.LogWarning("No function bound to OnBackgroundPushMessageReceived.");
            }
        }

        kiiPushPlugin.OnPushMessageReceived += _onPushMessageReceived;

        pushSetting = new PushSetting();
        apnsSetting = new APNSSetting();
        gcmSetting  = new GCMSetting();

        LogIn();
    }
コード例 #3
0
 public KiiPushMessage GetKiiPushMessage(KiiPushMessageData data, APNSSetting apns, GCMSetting gcm)
 {
     return KiiPushMessage.BuildWith (data)
         .EnableAPNS (EnableAPNS)
         .EnableGCM (EnableGCM)
         .SendAppID (SendAppID)
         .SendObjectScope (SendObjectScope)
         .SendOrigin (SendOrigin)
         .SendSender (SendSender)
         .SendToDevelopment (SendToDevelopment)
         .SendTopicId (SendTopicId)
         .SendToProduction (SendToProduction)
         .SendWhen (SendWhen)
         .WithAPNSMessage (apns.GetAPNSMessage ())
         .WithGCMMessage (gcm.GetGCMMessage ())
         .Build ();
 }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        Debug.Log ("#####Main.Start");
        this.kiiPushPlugin = GameObject.Find ("KiiPushPlugin").GetComponent<KiiPushPlugin> ();

        this.receivedCallback = (ReceivedMessage message) => {
            switch (message.PushMessageType)
            {
            case ReceivedMessage.MessageType.PUSH_TO_APP:
                Debug.Log ("#####PUSH_TO_APP Message");
                this.OnPushNotificationsReceived (message);
                break;
            case ReceivedMessage.MessageType.PUSH_TO_USER:
                Debug.Log ("#####PUSH_TO_USER Message");
                this.OnPushNotificationsReceived (message);
                break;
            case ReceivedMessage.MessageType.DIRECT_PUSH:
                Debug.Log ("#####DIRECT_PUSH Message");
                this.OnPushNotificationsReceived (message);
                break;
            }
        };
        this.kiiPushPlugin.OnPushMessageReceived += this.receivedCallback;

        pushSetting = new PushSetting ();
        apnsSetting = new APNSSetting ();
        gcmSetting = new GCMSetting ();

        if (KiiUser.CurrentUser != null)
        {
            Invoke ("registerPush", 0);
            return;
        }

        KiiUser.LogIn (USER_NAME, PASSWORD, (KiiUser u1, Exception e1) => {
            if (e1 != null)
            {
                KiiUser newUser = KiiUser.BuilderWithName (USER_NAME).Build ();
                Debug.Log ("#####Register");
                newUser.Register (PASSWORD, (KiiUser u2, Exception e2) => {
                    Debug.Log ("#####callback Register");
                    if (e2 != null)
                    {
                        Debug.Log ("#####failed to Register");
                        this.ShowException ("Failed to register user.", e2);
                        return;
                    }
                    else
                    {
                        Invoke ("registerPush", 0);
                    }
                });
            }
            else
            {
                Invoke ("registerPush", 0);
            }
        });
    }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("#####Main.Start");
        this.kiiPushPlugin = GameObject.Find("KiiPushPlugin").GetComponent <KiiPushPlugin> ();

        this.receivedCallback = (ReceivedMessage message) => {
            switch (message.PushMessageType)
            {
            case ReceivedMessage.MessageType.PUSH_TO_APP:
                Debug.Log("#####PUSH_TO_APP Message");
                this.OnPushNotificationsReceived(message);
                break;

            case ReceivedMessage.MessageType.PUSH_TO_USER:
                Debug.Log("#####PUSH_TO_USER Message");
                this.OnPushNotificationsReceived(message);
                break;

            case ReceivedMessage.MessageType.DIRECT_PUSH:
                Debug.Log("#####DIRECT_PUSH Message");
                this.OnPushNotificationsReceived(message);
                break;
            }
        };
        this.kiiPushPlugin.OnPushMessageReceived += this.receivedCallback;

        string lastMessage = this.kiiPushPlugin.GetLastMessage();

        if (lastMessage != null)
        {
            this.message += "#### launch from notification!!!! " + lastMessage;
            return;
        }

        pushSetting = new PushSetting();
        apnsSetting = new APNSSetting();
        gcmSetting  = new GCMSetting();

        if (KiiUser.CurrentUser != null)
        {
            Invoke("registerPush", 0);
            return;
        }

        KiiUser.LogIn(USER_NAME, PASSWORD, (KiiUser u1, Exception e1) => {
            if (e1 != null)
            {
                KiiUser newUser = KiiUser.BuilderWithName(USER_NAME).Build();
                Debug.Log("#####Register username="******"#####callback Register");
                    if (e2 != null)
                    {
                        Debug.Log("#####failed to Register");
                        this.ShowException("Failed to register user.", e2);
                        return;
                    }
                    else
                    {
                        Invoke("registerPush", 0);
                    }
                });
            }
            else
            {
                Debug.Log("#####Login username="******"registerPush", 0);
            }
        });
    }