Example #1
0
 private static void Enable(AbstractLogger logger, IDatabase database, IMixWebCallFactory mixWebCallFactory, string token, string tokenType, string provisionId, bool enableVisible, string swid, Action successCallback, Action failureCallback)
 {
     try
     {
         TogglePushNotificationRequest togglePushNotificationRequest = new TogglePushNotificationRequest();
         togglePushNotificationRequest.PushToken = new PushToken
         {
             Token     = token,
             TokenType = tokenType
         };
         togglePushNotificationRequest.State             = (enableVisible ? "ALL" : "ONLY_SILENT");
         togglePushNotificationRequest.IosProvisioningId = provisionId;
         TogglePushNotificationRequest request = togglePushNotificationRequest;
         IWebCall <TogglePushNotificationRequest, BaseResponse> webCall = mixWebCallFactory.PushNotificationsSettingPost(request);
         webCall.OnResponse += delegate
         {
             try
             {
                 database.UpdateSessionDocument(swid, delegate(SessionDocument sessionDoc)
                 {
                     sessionDoc.PushNotificationToken           = token;
                     sessionDoc.PushNotificationTokenType       = tokenType;
                     sessionDoc.VisiblePushNotificationsEnabled = enableVisible;
                     sessionDoc.ProvisionId = provisionId;
                 });
                 successCallback();
             }
             catch (Exception ex2)
             {
                 logger.Critical("Unhandled exception: " + ex2);
                 failureCallback();
             }
         };
         webCall.OnError += delegate
         {
             failureCallback();
         };
         webCall.Execute();
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         failureCallback();
     }
 }