コード例 #1
0
ファイル: NotificationDemo.cs プロジェクト: georgex1/rednit
        private void DrawRegisterAPI()
        {
            GUILayout.Label("Register/Unregister", kSubTitleStyle);

            if (GUILayout.Button("Register Notification Types [None, Alert, Badge and Sound]"))
            {
                RegisterNotificationTypes(m_notificationType);
                AddNewResult("Registered Types : " + m_notificationType.GetValue());
            }

            if (GUILayout.Button("Register For Remote Notifications"))
            {
                RegisterForRemoteNotifications();
            }

            if (GUILayout.Button("Unregister For Remote Notifications"))
            {
                UnregisterForRemoteNotifications();
                AddNewResult("Unregistered for remote notifications");
            }
        }
コード例 #2
0
        protected override void OnGUIWindow()
        {
            base.OnGUIWindow();

            RootScrollView.BeginScrollView();
            {
                // Start vertical column
                GUILayout.BeginVertical(UISkin.scrollView);
                {
                    GUILayout.Label("Register/Unregister", kSubTitleStyle);

                    if (GUILayout.Button("Register Notification Types [None, Alert, Badge and Sound]"))
                    {
                        RegisterNotificationTypes(m_notificationType);
                        AddNewResult("Registered Types : " + m_notificationType.GetValue());
                    }

                    if (GUILayout.Button("Register For Remote Notifications"))
                    {
                        RegisterForRemoteNotifications();
                    }

                    if (GUILayout.Button("Unregister For Remote Notifications"))
                    {
                        UnregisterForRemoteNotifications();
                        AddNewResult("Unregistered for remote notifications");
                    }
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(UISkin.scrollView);
                {
                    GUILayout.Label("Schedule Notifications", kSubTitleStyle);

                    if (GUILayout.Button("Schedule Local Notification (After 1min)"))
                    {
                        // Schedules a local notification after 1 min
                        string _nID = ScheduleLocalNotification(CreateNotification(60));

                        // Add notification id to list
                        m_scheduledNotificationIDList.Add(_nID);

                        // Update info
                        AddNewResult("Newly scheduled notification ID = " + _nID);
                    }
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(UISkin.scrollView);
                {
                    GUILayout.Label("Cancel Notifications", kSubTitleStyle);

                    if (GUILayout.Button("Cancel Local Notification"))
                    {
                        if (m_scheduledNotificationIDList.Count > 0)
                        {
                            string _nID = m_scheduledNotificationIDList[0] as string;

                            AddNewResult("Cancelling notification with ID=" + _nID);

                            CancelLocalNotification(_nID);

                            // Remove notification id
                            m_scheduledNotificationIDList.RemoveAt(0);
                        }
                        else
                        {
                            AddNewResult("No Scheduled Local Notifications");
                        }
                    }

                    if (GUILayout.Button("Cancel All Local Notifications"))
                    {
                        // Clearing list
                        m_scheduledNotificationIDList.Clear();

                        // Cancelling all notifications
                        CancelAllLocalNotifications();

                        // Update info
                        AddNewResult("Scheduled notifications are invalidated");
                    }

                    if (GUILayout.Button("Clear Notifications"))
                    {
                        ClearNotifications();

                        // Update info
                        AddNewResult("Cleared notifications from notification bar.");
                    }
                }
                GUILayout.EndVertical();
            }
            RootScrollView.EndScrollView();


            DrawResults();

            DrawPopButton();
        }