void OnGUI() { ScalableGUI gui = new ScalableGUI(); gui.Label(5, 5, 310, 20, "Push2App scene"); if (gui.Button(200, 5, 120, 35, "-> Push2User")) { this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback; Application.LoadLevel("push2user"); } this.payload = gui.TextField(0, 45, 320, 50, this.payload); if (gui.Button(0, 100, 160, 50, "Create Object")) { KiiBucket bucket = KiiUser.CurrentUser.Bucket(BUCKET_NAME); KiiObject obj = bucket.NewKiiObject(); obj["payload"] = this.payload; obj.Save((KiiObject o, Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("Failed to save object", e); return; } this.message = "#####creating object is successful!!"; }); } if (gui.Button(160, 100, 160, 50, "Clear Log")) { this.message = ""; } if (gui.Button(0, 150, 160, 50, "Register Push")) { Invoke("registerPush", 0); } if (gui.Button(160, 150, 160, 50, "Unregister Push")) { this.kiiPushPlugin.UnregisterPush((Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("#####Unregister push is failed!!", e); return; } this.message = "#####Unregister push is successful!!"; }); } gui.Label(5, 210, 310, 270, this.message, 10); }
void OnGUI() { ScalableGUI gui = new ScalableGUI (); if (pushScreen == true && apnsScreen == false && gcmScreen == false) { if (gui.Button (0, 10, 160, 50, "<< Back to main")) { pushScreen = false; } gui.Label (5, 70, 310, 30, "Push settings screen", 18); if (gui.Toggle (0, 100, 160, 50, pushSetting.SendAppID, "SendAppID")) { pushSetting.SendAppID = !pushSetting.SendAppID; } if (gui.Toggle (160, 100, 160, 50, pushSetting.SendObjectScope, "SendObjectScope")) { pushSetting.SendObjectScope = !pushSetting.SendObjectScope; } if (gui.Toggle (0, 150, 160, 50, pushSetting.SendOrigin, "SendOrigin")) { pushSetting.SendOrigin = !pushSetting.SendOrigin; } if (gui.Toggle (160, 150, 160, 50, pushSetting.SendSender, "SendSender")) { pushSetting.SendSender = !pushSetting.SendSender; } if (gui.Toggle (0, 200, 160, 50, pushSetting.SendTopicId, "SendTopicId")) { pushSetting.SendTopicId = !pushSetting.SendTopicId; } if (gui.Toggle (160, 200, 160, 50, pushSetting.SendWhen, "SendWhen")) { pushSetting.SendWhen = !pushSetting.SendWhen; } if (gui.Toggle (0, 250, 160, 50, pushSetting.SendToProduction, "SendToProduction")) { pushSetting.SendToProduction = !pushSetting.SendToProduction; } if (gui.Toggle (160, 250, 160, 50, pushSetting.SendToDevelopment, "SendToDevelopment")) { pushSetting.SendToDevelopment = !pushSetting.SendToDevelopment; } } else if (pushScreen == false && apnsScreen == true && gcmScreen == false) { if (gui.Button (0, 10, 160, 50, "<< Back to main")) { apnsScreen = false; } gui.Label (5, 70, 310, 30, "APNs settings screen", 18); if (gui.Toggle (0, 100, 160, 50, (apnsSetting.ContentAvailable == 1) ? true : false, "content-available")) { if (apnsSetting.ContentAvailable == 0) { apnsSetting.ContentAvailable = 1; } else { apnsSetting.ContentAvailable = 0; } } gui.Label (5, 160, 310, 20, "APNs alert body", 10); apnsSetting.AlertBody = gui.TextField (0, 190, 320, 50, apnsSetting.AlertBody); } else if (pushScreen == false && apnsScreen == false && gcmScreen == true) { if (gui.Button (0, 10, 160, 50, "<< Back to main")) { gcmScreen = false; } gui.Label (5, 70, 310, 30, "GCM settings screen", 18); } else { gui.Label (5, 5, 310, 20, "Push2User scene"); if (gui.Button (200, 5, 120, 35, "-> Push2App")) { this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback; Application.LoadLevel ("push2app"); } this.payload = gui.TextField (0, 45, 320, 50, this.payload); if (gui.Button (0, 100, 160, 40, "Send Message")) { sendMessage (); } if (gui.Button (160, 100, 160, 40, "Clear Log")) { this.message = "--- Logs will show here ---"; } if (gui.Button (0, 140, 160, 40, "Register Push")) { Invoke ("registerPush", 0); } if (gui.Button (160, 140, 160, 40, "Unregister Push")) { this.kiiPushPlugin.UnregisterPush ((Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Unregister push is failed!!", e); return; } this.message = "#####Unregister push is successful!!"; }); } if (gui.Button (0, 180, 160, 40, "Subscribe topic")) { KiiUser user = KiiUser.CurrentUser; KiiTopic topic = user.Topic (TOPIC_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.Subscribe (topic, (KiiSubscribable target, Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Subscribe is failed!!", e); return; } this.message = "#####Subscribe is successful!!"; }); } if (gui.Button (160, 180, 160, 40, "Unsubscribe topic")) { KiiUser user = KiiUser.CurrentUser; KiiTopic topic = user.Topic (TOPIC_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.Unsubscribe (topic, (KiiSubscribable target, Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Unsubscribe is failed!!", e); return; } this.message = "#####Unsubscribe is successful!!"; }); } if (gui.Button (0, 220, 160, 40, "Check subscription")) { KiiUser user = KiiUser.CurrentUser; KiiTopic topic = user.Topic (TOPIC_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.IsSubscribed (topic, (KiiSubscribable target, bool isSubscribed, Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Check subscription is failed!!", e); return; } this.message = "#####Subscription status : " + isSubscribed; }); } if (gui.Button (160, 220, 160, 40, "Push settings >>")) { pushScreen = true; } if (gui.Toggle (0, 260, 160, 40, apnsSetting.Enable, "Enable APNs")) { apnsSetting.Enable = !apnsSetting.Enable; } GUI.enabled = apnsSetting.Enable; if (gui.Button (160, 260, 160, 40, "APNs settings >>")) { apnsScreen = true; } GUI.enabled = true; if (gui.Toggle (0, 300, 160, 40, gcmSetting.Enable, "Enable GCM")) { gcmSetting.Enable = !gcmSetting.Enable; } GUI.enabled = gcmSetting.Enable; if (gui.Button (160, 300, 160, 40, "GCM settings >>")) { gcmScreen = true; } GUI.enabled = true; gui.TextArea (5, 350, 310, 130, this.message, 10); } }
void OnGUI() { ScalableGUI gui = new ScalableGUI(); if (pushScreen == true && apnsScreen == false && gcmScreen == false) { if (gui.Button(0, 10, 160, 50, "<< Back to main")) { pushScreen = false; } gui.Label(5, 70, 310, 30, "Push settings screen", 18); if (gui.Toggle(0, 100, 160, 50, pushSetting.SendAppID, "SendAppID")) { pushSetting.SendAppID = !pushSetting.SendAppID; } if (gui.Toggle(160, 100, 160, 50, pushSetting.SendObjectScope, "SendObjectScope")) { pushSetting.SendObjectScope = !pushSetting.SendObjectScope; } if (gui.Toggle(0, 150, 160, 50, pushSetting.SendOrigin, "SendOrigin")) { pushSetting.SendOrigin = !pushSetting.SendOrigin; } if (gui.Toggle(160, 150, 160, 50, pushSetting.SendSender, "SendSender")) { pushSetting.SendSender = !pushSetting.SendSender; } if (gui.Toggle(0, 200, 160, 50, pushSetting.SendTopicId, "SendTopicId")) { pushSetting.SendTopicId = !pushSetting.SendTopicId; } if (gui.Toggle(160, 200, 160, 50, pushSetting.SendWhen, "SendWhen")) { pushSetting.SendWhen = !pushSetting.SendWhen; } if (gui.Toggle(0, 250, 160, 50, pushSetting.SendToProduction, "SendToProduction")) { pushSetting.SendToProduction = !pushSetting.SendToProduction; } if (gui.Toggle(160, 250, 160, 50, pushSetting.SendToDevelopment, "SendToDevelopment")) { pushSetting.SendToDevelopment = !pushSetting.SendToDevelopment; } } else if (pushScreen == false && apnsScreen == true && gcmScreen == false) { if (gui.Button(0, 10, 160, 50, "<< Back to main")) { apnsScreen = false; } gui.Label(5, 70, 310, 30, "APNs settings screen", 18); if (gui.Toggle(0, 100, 160, 50, (apnsSetting.ContentAvailable == 1) ? true : false, "content-available")) { if (apnsSetting.ContentAvailable == 0) { apnsSetting.ContentAvailable = 1; } else { apnsSetting.ContentAvailable = 0; } } gui.Label(5, 160, 310, 20, "APNs alert body", 10); apnsSetting.AlertBody = gui.TextField(0, 190, 320, 50, apnsSetting.AlertBody); } else if (pushScreen == false && apnsScreen == false && gcmScreen == true) { if (gui.Button(0, 10, 160, 50, "<< Back to main")) { gcmScreen = false; } gui.Label(5, 70, 310, 30, "GCM settings screen", 18); } else { gui.Label(5, 5, 310, 20, "Push2User scene"); if (gui.Button(200, 5, 120, 35, "-> Push2App")) { this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback; Application.LoadLevel("push2app"); } this.payload = gui.TextField(0, 45, 320, 50, this.payload); if (gui.Button(0, 100, 160, 50, "Send Message")) { sendMessage(); } if (gui.Button(160, 100, 160, 50, "Clear Log")) { this.message = ""; } if (gui.Button(0, 150, 160, 50, "Register Push")) { Invoke("registerPush", 0); } if (gui.Button(160, 150, 160, 50, "Unregister Push")) { this.kiiPushPlugin.UnregisterPush((Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("#####Unregister push is failed!!", e); return; } this.message = "#####Unregister push is successful!!"; }); } if (gui.Button(160, 200, 160, 50, "Push settings >>")) { pushScreen = true; } if (gui.Toggle(0, 250, 160, 50, apnsSetting.Enable, "Enable APNs")) { apnsSetting.Enable = !apnsSetting.Enable; } GUI.enabled = apnsSetting.Enable; if (gui.Button(160, 250, 160, 50, "APNs settings >>")) { apnsScreen = true; } GUI.enabled = true; if (gui.Toggle(0, 300, 160, 50, gcmSetting.Enable, "Enable GCM")) { gcmSetting.Enable = !gcmSetting.Enable; } GUI.enabled = gcmSetting.Enable; if (gui.Button(160, 300, 160, 50, "GCM settings >>")) { gcmScreen = true; } GUI.enabled = true; gui.Label(5, 360, 310, 120, this.message, 10); } }
void OnGUI() { ScalableGUI gui = new ScalableGUI (); gui.Label (5, 5, 310, 20, "Push2App scene"); if (gui.Button (200, 5, 120, 35, "-> Push2User")) { this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback; Application.LoadLevel ("push2user"); } this.payload = gui.TextField (0, 45, 320, 50, this.payload); if (gui.Button (0, 100, 160, 50, "Create Object")) { KiiBucket bucket = KiiUser.CurrentUser.Bucket (BUCKET_NAME); KiiObject obj = bucket.NewKiiObject (); obj ["payload"] = this.payload; obj.Save ((KiiObject o, Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("Failed to save object", e); return; } this.message = "#####creating object is successful!!"; }); } if (gui.Button (160, 100, 160, 50, "Clear Log")) { this.message = "--- Logs will show here ---"; } if (gui.Button (0, 150, 160, 50, "Register Push")) { Invoke ("registerPush", 0); } if (gui.Button (160, 150, 160, 50, "Unregister Push")) { this.kiiPushPlugin.UnregisterPush ((Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Unregister push is failed!!", e); return; } this.message = "#####Unregister push is successful!!"; }); } if (gui.Button (0, 200, 160, 50, "Subscribe bucket")) { KiiUser user = KiiUser.CurrentUser; KiiBucket bucket = user.Bucket (BUCKET_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.Subscribe (bucket, (KiiSubscribable target, Exception e) => { if (e != null) { if (e is ConflictException) { this.message += "\n" + "Bucket is already subscribed"; return; } Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Subscribe is failed!!", e); return; } this.message = "#####Subscribe is successful!!"; }); } if (gui.Button (160, 200, 160, 50, "Unsubscribe bucket")) { KiiUser user = KiiUser.CurrentUser; KiiBucket bucket = user.Bucket (BUCKET_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.Unsubscribe (bucket, (KiiSubscribable target, Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Unsubscribe is failed!!", e); return; } this.message = "#####Unsubscribe is successful!!"; }); } if (gui.Button (0, 250, 160, 50, "Check subscription")) { KiiUser user = KiiUser.CurrentUser; KiiBucket bucket = user.Bucket (BUCKET_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.IsSubscribed (bucket, (KiiSubscribable target, bool isSubscribed, Exception e) => { if (e != null) { Debug.Log ("#####" + e.Message); Debug.Log ("#####" + e.StackTrace); this.ShowException ("#####Check subscription is failed!!", e); return; } this.message = "#####Subscription status : " + isSubscribed; }); } gui.TextArea (5, 310, 310, 170, this.message, 10); }
void OnGUI() { ScalableGUI gui = new ScalableGUI(); gui.Label(5, 5, 310, 20, "Push2App scene"); if (gui.Button(200, 5, 120, 35, "-> Push2User")) { this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback; Application.LoadLevel("push2user"); } this.payload = gui.TextField(0, 45, 320, 50, this.payload); if (gui.Button(0, 100, 160, 50, "Create Object")) { KiiBucket bucket = KiiUser.CurrentUser.Bucket(BUCKET_NAME); KiiObject obj = bucket.NewKiiObject(); obj ["payload"] = this.payload; obj.Save((KiiObject o, Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("Failed to save object", e); return; } this.message = "#####creating object is successful!!"; }); } if (gui.Button(160, 100, 160, 50, "Clear Log")) { this.message = "--- Logs will show here ---"; } if (gui.Button(0, 150, 160, 50, "Register Push")) { Invoke("registerPush", 0); } if (gui.Button(160, 150, 160, 50, "Unregister Push")) { this.kiiPushPlugin.UnregisterPush((Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("#####Unregister push is failed!!", e); return; } this.message = "#####Unregister push is successful!!"; }); } if (gui.Button(0, 200, 160, 50, "Subscribe bucket")) { KiiUser user = KiiUser.CurrentUser; KiiBucket bucket = user.Bucket(BUCKET_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.Subscribe(bucket, (KiiSubscribable target, Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("#####Subscribe is failed!!", e); return; } this.message = "#####Subscribe is successful!!"; }); } if (gui.Button(160, 200, 160, 50, "Unsubscribe bucket")) { KiiUser user = KiiUser.CurrentUser; KiiBucket bucket = user.Bucket(BUCKET_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.Unsubscribe(bucket, (KiiSubscribable target, Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("#####Unsubscribe is failed!!", e); return; } this.message = "#####Unsubscribe is successful!!"; }); } if (gui.Button(0, 250, 160, 50, "Check subscription")) { KiiUser user = KiiUser.CurrentUser; KiiBucket bucket = user.Bucket(BUCKET_NAME); KiiPushSubscription subscription = user.PushSubscription; subscription.IsSubscribed(bucket, (KiiSubscribable target, bool isSubscribed, Exception e) => { if (e != null) { Debug.Log("#####" + e.Message); Debug.Log("#####" + e.StackTrace); this.ShowException("#####Check subscription is failed!!", e); return; } this.message = "#####Subscription status : " + isSubscribed; }); } gui.TextArea(5, 310, 310, 170, this.message, 10); }
void OnGUI() { this.entryNameValue = gui.TextField( 10, 10, 300, 50, this.entryNameValue); this.versionValue = gui.TextField( 10, 70, 300, 50, this.versionValue); if (gui.Button( 10, 130, 300, 60, "ServerCodeEntry(entryName)")) { try { execEntry(Kii.ServerCodeEntry(this.entryNameValue)); } catch (Exception e) { this.labelText = e.ToString(); } } if (gui.Button( 10, 200, 300, 60, "ServerCodeEntry(entryName, version)")) { try { execEntry(Kii.ServerCodeEntry(this.entryNameValue, this.versionValue)); } catch (Exception e) { this.labelText = e.ToString(); } } if (gui.Button( 10, 270, 145, 60, "User login")) { this.labelText = ""; string username = "******" + DateTime.Now.Ticks.ToString(); KiiUser user = KiiUser.BuilderWithName(username).Build(); user.Register("pa$$sword", (KiiUser u, Exception e1) => { if (e1 == null) { this.labelText = "SUCCESS:\nuser="******"User logout")) { KiiUser.LogOut(); this.labelText = "User logged out"; } gui.TextField( 10, 350, 300, 120, this.labelText); }