void Cotc_GotDomainLoopEvent(DomainEventLoop sender, EventLoopArgs args)
 {
     // When we receive a message, it means that the pending notification has been approved, so reset the application badge
     #if UNITY_IPHONE
     if (args.Message.Has("osn")) {
         Debug.LogWarning ("Will clear events");
         UnityEngine.iOS.NotificationServices.ClearRemoteNotifications();
         var setCountNotif = new UnityEngine.iOS.LocalNotification();
         setCountNotif.fireDate = System.DateTime.Now;
         setCountNotif.applicationIconBadgeNumber = -1;
         setCountNotif.hasAction = false;
         UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(setCountNotif);
     }
     #endif
 }
        void Cotc_GotDomainLoopEvent(DomainEventLoop sender, EventLoopArgs args)
        {
            // When we receive a message, it means that the pending notification has been approved, so reset the application badge
#if UNITY_IPHONE
            if (args.Message.Has("osn"))
            {
                Debug.LogWarning("Will clear events");
                UnityEngine.iOS.NotificationServices.ClearRemoteNotifications();
                var setCountNotif = new UnityEngine.iOS.LocalNotification();
                setCountNotif.fireDate = System.DateTime.Now;
                setCountNotif.applicationIconBadgeNumber = -1;
                setCountNotif.hasAction = false;
                UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(setCountNotif);
            }
#endif
        }
        /// <summary>
        /// Once an event is retrieved from the server, check its type and call the corresponding callback.
        /// </summary>
        /// <param name="sender">The event loop instance which raised the event.</param>
        /// <param name="eventData">Received event's data.</param>
        private static void OnEventReceived(DomainEventLoop sender, EventLoopArgs eventData)
        {
            // Get the Bundle data from the raised event
            Bundle eventBundle = eventData.Message;

            if (verboseEventLoop)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:EventFeatures] Received event ›› {0}", eventBundle.ToString()));
            }

            switch (eventBundle["type"].AsString())
            {
            // Event type: message sent from the BackOffice
            case "backoffice":
                if (Event_BackOfficeMessage == null)
                {
                    DebugLogs.LogError(string.Format(noEventCallbackFormat, "Event_BackOfficeMessage"));
                }
                else
                {
                    Event_BackOfficeMessage(eventBundle);
                }
                break;

            // Event type: another gamer added the currently logged in one as friend (automatic)
            case "friend.add":
                DebugLogs.LogWarning(string.Format(soonDeprecatedEvent, "friend.add"));
                break;

            // Event type: another gamer added the currently logged in one as blacklisted (automatic)
            case "friend.blacklist":
                DebugLogs.LogWarning(string.Format(soonDeprecatedEvent, "friend.blacklist"));
                break;

            // Event type: another gamer removed the currently logged in one from friend/blacklisted (automatic)
            case "friend.forget":
                DebugLogs.LogWarning(string.Format(soonDeprecatedEvent, "friend.forget"));
                break;

            // Event type: another gamer used the currently logged in one's referral code (automatic)
            case "godchildren":
                if (Event_NewGodchild == null)
                {
                    DebugLogs.LogError(string.Format(noEventCallbackFormat, "Event_NewGodchild"));
                }
                else
                {
                    Event_NewGodchild(eventBundle);
                }
                break;

            // Event type: message sent from another gamer (our "custom" events sent by gamer.Community.SendEvent() are of this type)
            case "user":
                OnCustomEventReceived(eventBundle);
                break;

            // Unhandled event types
            default:
                DebugLogs.LogError(string.Format("[CotcSdkTemplate:EventFeatures] An unhandled event has been received ›› {0}", eventBundle.ToString()));
                break;
            }
        }
Exemple #4
0
 private void Loop_ReceivedEvent(DomainEventLoop sender, EventLoopArgs e)
 {
     Debug.Log("Received event of type " + e.Message.Type + ": " + e.Message.ToJson());
 }