RefreshDeviceToken() public méthode

Refreshes expired device token in DB
public RefreshDeviceToken ( string oldId, string newId ) : void
oldId string
newId string
Résultat void
Exemple #1
0
        private string ProcessUpdate(string oldToken, string newToken, long userId, DeviceType deviceType, ApplicationType?appType)
        {
            try
            {
                IPushNotificationService notificationSrv = new DefaultPushNotificationService();

                if (notificationSrv.IsTokenSubscribed(oldToken))
                {
                    if (!newToken.Equals(oldToken))
                    {
                        notificationSrv.RefreshDeviceToken(oldToken, newToken);
                        logger.InfoFormat("Device token {0} successfully updated with new token {1}", oldToken, newToken);
                        return(string.Format("Device token {0} successfully updated with new token {1}", oldToken, newToken));
                    }
                }
                else if (!notificationSrv.IsTokenSubscribed(newToken))
                {
                    notificationSrv.SubscribeDeviceToken(newToken, deviceType, userId, appType);
                    return(string.Format("New device token {0} successfully inserted in database", newToken));
                }
                return(null);
            }
            catch (Exception e)
            {
                throw new ApplicationException(e.Message);
            }
        }
        private string ProcessUpdate(string oldToken, string newToken, long userId, DeviceType deviceType, ApplicationType? appType)
        {
            try
            {
                IPushNotificationService notificationSrv = new DefaultPushNotificationService();

                if (notificationSrv.IsTokenSubscribed(oldToken))
                {
                    if (!newToken.Equals(oldToken))
                    {
                        notificationSrv.RefreshDeviceToken(oldToken, newToken);
                        logger.InfoFormat("Device token {0} successfully updated with new token {1}", oldToken, newToken);
                        return string.Format("Device token {0} successfully updated with new token {1}", oldToken, newToken);
                    }

                }
                else if (!notificationSrv.IsTokenSubscribed(newToken))
                {
                    notificationSrv.SubscribeDeviceToken(newToken, deviceType, userId, appType);
                    return string.Format("New device token {0} successfully inserted in database", newToken);
                }
                return null;
            }
            catch (Exception e)
            {
                throw new ApplicationException(e.Message);
            }
        }