示例#1
0
        void SyncDataAndNotifications()
        {
            //check before so can get latest update if reset
            CheckForGoLive();

            Console.WriteLine("SyncDataAndNotificationss");
            NotifySyncing();
            ServiceSyncStatus status = MyMoodService.Current.SyncDataWithServer();

            NotifySyncComplete(status);

            string version = NSBundle.MainBundle.ObjectForInfoDictionary("Version").ToString();

            if (version != ApplicationState.Current.CurrentVersion && ApplicationState.Current.ForceUpdate > 0)
            {
                InvokeOnMainThread(delegate {
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ForceVersionUpdate", null);
                });
            }

            if (status.HasPromptUpdates)
            {
                InvokeOnMainThread(delegate {
                    Console.WriteLine("Has Prompt Updates");

                    NotificationManager.SyncNotificationsWithPrompts(MoodPrompt.All());
                    ShowBadgeNumber();

                    NSNotificationCenter.DefaultCenter.PostNotificationName("PromptsUpdated", null);
                });
            }

            //check if go live has been set
            CheckForGoLive();
        }
示例#2
0
 void NotifySyncComplete(ServiceSyncStatus status)
 {
     InvokeOnMainThread(delegate {
         NSString key          = new NSString("SyncStatus");
         var level             = status.SuccessLevel.ToString();
         NSDictionary userInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(level), key);
         NSNotificationCenter.DefaultCenter.PostNotificationName("SyncWithServerComplete", null, userInfo);
     });
 }