public IActionResult AddToken(int userId, [FromBody] DeviceToken request) { _logger.LogWarning(JsonConvert.SerializeObject(request)); if (userId != 0 && !String.IsNullOrEmpty(request.token)) { if (_tokens.AddToken(userId, request.token)) { _notificationManager.SubscribeTopic(request.token, userId.ToString()); } _logger.LogWarning(GetTokens()); return(Ok(JsonConvert.SerializeObject( new { success = userId, token = request.token }) )); } return(BadRequest(JsonConvert.SerializeObject( new { error = "invalid_request", error_description = "Token is invalid." }) )); }
public List <DeviceStatusDto> GetAllHistoryForDevice([FromBody] string deviceToken) { // TODO SECURITY ISSUE: Make sure the user for the device and the currently logged in user are the same. User user = this._context.Users.Include(u => u.DeviceTokens).ThenInclude(dt => dt.DeviceEvents).FirstOrDefault(u => u.Id == Misc.GetIdFromClaimsPrincipal(User)); DeviceToken device = user.DeviceTokens.FirstOrDefault((dv) => { return(dv.Token == deviceToken); }); if (device != null) { List <DeviceStatusDto> statuses = new List <DeviceStatusDto>(); foreach (DeviceEvent de in device.DeviceEvents) { if (de.Device == null) { continue; } statuses.Add(new DeviceStatusDto { changeOfStatus = de.EventDate, deviceToken = device.Token, isOnline = de.IsOnline }); } return(statuses.OrderByDescending(status => status.changeOfStatus).ToList()); } this._logger.LogError("DeviceStatus_NoDevice", "User: {0}, device Token: {1}", user.Id, device.Token); throw new Exception("No device with this deviceId found for user"); }
public EnhancedNotification(DeviceToken deviceToken, IPayload payload, uint identifier, TimeSpan?expiry) { this.deviceToken = deviceToken; this.payload = payload; this.identifier = identifier; this.expiry = expiry; }
public ActionResult <List <SensorData> > GetLongTermTempHistory([FromBody] string deviceToken) { DeviceToken dt = this._context.DeviceTokens.FirstOrDefault(d => d.Token == deviceToken); if (this.IsValidDeviceToken(dt) == false) { return(BadRequest()); } return(new List <SensorData>() { new SensorData { Device = dt, EventTime = DateTime.Now.AddDays(-7), Id = 1, IsAggregate = true, Value = 19 }, new SensorData { Device = dt, EventTime = DateTime.Now.AddDays(-8), Id = 2, IsAggregate = true, Value = 21 }, new SensorData { Device = dt, EventTime = DateTime.Now.AddDays(-9), Id = 3, IsAggregate = true, Value = 25 } }); }
public async void EmailVerification() { DeviceToken DO = new DeviceToken(); try { DO = await sc.CheckMail(CurrentUser.getUserId()); } catch (Exception exe) { LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString()); } if (DO.VerificationStatus == 1) { Intent intent = new Intent(this, typeof(TabActivity)); StartActivity(intent); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Sorry"); alert.SetMessage("Please verify your mail id"); alert.SetNegativeButton("Ok", delegate { }); Dialog dialog = alert.Create(); dialog.Show(); } }
public EnhancedNotification(DeviceToken deviceToken, IPayload payload, uint identifier, TimeSpan? expiry) { this.deviceToken = deviceToken; this.payload = payload; this.identifier = identifier; this.expiry = expiry; }
public XSTSRequest(UserToken userToken, string relyingParty = "http://xboxlive.com", string tokenType = "JWT", string sandboxId = "RETAIL", DeviceToken deviceToken = null, TitleToken titleToken = null) { RelyingParty = relyingParty; TokenType = tokenType; Properties = new Dictionary <string, object> { { "UserTokens", new string[] { userToken.Jwt } }, { "SandboxId", sandboxId } }; if (deviceToken != null) { Properties.Add("DeviceToken", deviceToken.Jwt); } if (titleToken != null) { Properties.Add("TitleToken", titleToken.Jwt); } }
public async Task <ActionResult> DeviceOffline([FromBody] DeviceTokenDto devTok) { if (devTok == null || string.IsNullOrWhiteSpace(devTok.deviceToken)) { this._logger.LogError("InternalCommsController_DevOff_NoToken"); return(BadRequest()); } DeviceToken dt = this._context.DeviceTokens.FirstOrDefault(d => d.Token == devTok.deviceToken); if (dt == null) { this._logger.LogError("InternalCommsController_DevOff_NoSuchDevice"); return(StatusCode(500, "No User for this device token")); } dt.IsDeviceOnline = false; dt.DeviceEvents.Add(new DeviceEvent(DateTime.UtcNow, false)); await this._context.SaveChangesAsync(); User usr = this._context.Users.FirstOrDefault(u => u.Id == dt.UserId); if (usr == null) { this._logger.LogError("InternalCommsController_DevOff_NoUserForDeviceToken"); return(StatusCode(500, "No User for this device token")); } this._pushNotificationService.BroadcastDeviceOfflineNotification(usr, dt.Token); return(Ok()); }
public RestfulAPIHelper(string email, string password) { _email = email; _password = password; try { string developerMode = ConfigurationManager.AppSettings["APIService.DeveloperMode"]; if (string.IsNullOrEmpty(developerMode) == false && developerMode.Equals("true")) { _sfAPIServiceBaseURI = "https://sfapiservice.trafficmanager.net/"; // Development } else { _sfAPIServiceBaseURI = ConfigurationManager.AppSettings["API.Uri"]; if (string.IsNullOrEmpty(this._sfAPIServiceBaseURI)) { _sfAPIServiceBaseURI = "https://msfapiservice.trafficmanager.net//"; // Production } } } catch (Exception) { _sfAPIServiceBaseURI = "https://msfapiservice.trafficmanager.net//"; // Production } Logger.showDebug("RestfulAPIHelper", "sfAPIServiceBaseURI={0}".FormatInvariant(_sfAPIServiceBaseURI)); _sfAPIServiceTokenEndPoint = _sfAPIServiceBaseURI + "token"; _sfAPIServiceDeviceAPIURI = _sfAPIServiceBaseURI + "device-api/device"; _currentDeviceToken = null; ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); }); }
public void Should_Update() { DeviceToken deviceToken = new DeviceToken(userProfileId, deviceTokenValue, deviceVersion, deviceName, model, userDeviceId, timeStamp, sourceIP, android); deviceToken.Update(userProfileId, deviceTokenValue, deviceVersion, deviceName, model, userDeviceId, timeStamp, sourceIP, android); Assert.Equal(deviceTokenValue, deviceToken.DeviceTokenValue); }
public void Should_SetActive() { DeviceToken deviceToken = new DeviceToken(userProfileId, deviceTokenValue, deviceVersion, deviceName, model, userDeviceId, timeStamp, sourceIP, android); deviceToken.SetActive(); Assert.True(deviceToken.IsActive); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { List <WateringScheduleItem> scheduleItems = this.GetWateringSchedulesToRun(); DateTime now = DateTime.UtcNow; this._logger.LogInformation("ScheduledWateringItemCount", "{0} waterings at {1}", scheduleItems.Count, now); // Go through each item and add an event on the dispatcher // log each item in a meaningful way scheduleItems.ForEach((item) => { DeviceToken token = item.User.DeviceTokens.FirstOrDefault(); if (token != null) { this._dispatcher.WaterNow(this, new WaterNowArgs { Token = token.Token, WaterNow = new Dtos.WaterNowDto { level = item.Level, duration = item.Duration } }); item.LastRun = new ScheduledRun { Level = item.Level, Duration = item.Duration, StartTime = now, User = item.User, Id = Guid.NewGuid() }; this._dbContext.SaveChanges(); this._logger.LogInformation("ScheduledWatering", "{0} at {1}", item.StartTime, now); } else { this._logger.LogError("ScheduledWatering_NoToken", "User: {0}", item.User.Id); // TODO: should the user be informed of this? maybe not right now } }); await Task.Delay(1000 * 10, stoppingToken); } }
/// <summary> /// 注册DeviceToken /// </summary> /// <param name="clientID">终端唯一标识</param> /// <param name="userID">用户ID</param> /// <param name="token">会话令牌</param> /// <param name="platform">平台(终端平台iphone\android)</param> /// <param name="ver">版本号</param> /// http://61.135.144.37:8090/Api/DeviceToken/GetDeviceTokenInfo.do?clientID=12868&userID=12868&token=12868&platform=android&ver=1.0 public void GetDeviceTokenInfo(string clientID, int?userID, string token, string platform, string ver) { if (userID == null) { userID = 0; } if (!string.IsNullOrEmpty(clientID) && !string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(platform) && !string.IsNullOrEmpty(ver)) { DeviceToken _deviceToken = new DeviceToken(); _deviceToken.ClientID = clientID; _deviceToken.UserID = userID.Value; _deviceToken.Token = token; _deviceToken.Platform = platform; _deviceToken.Ver = ver; _result.Code = _deviceTokenService.InsertDeviceToken(_deviceToken); if (_result.Code > 0) { _result.Data = "ok"; } else { _result.Data = "记录存在"; } } else { _result.Data = "对不起,参数不能为空!"; } string _jsonString = JsonConvert.SerializeObject(_result, Formatting.Indented); RenderText(_jsonString); CancelLayout(); }
/// <summary> /// Registers the currently used device for receiving push notifications. Returns a globally unique identifier of the push notification subscription /// </summary> public static Task <PushReceiverId> RegisterDeviceAsync( this Client client, DeviceToken deviceToken = default, int[] otherUserIds = default) { return(client.ExecuteAsync(new RegisterDevice { DeviceToken = deviceToken, OtherUserIds = otherUserIds })); }
public void Should_Construct_DeviceToken_Third() { DeviceToken deviceToken = new DeviceToken(deviceTokenValue, deviceVersion, deviceName, model, userDeviceId, new List <DeviceTokenNotification>() { }); deviceToken.ShouldNotBeNull(); }
/// <summary> /// Register / Update a Device Registration /// Registers a device token with extended properties with the Urban Airship site, this can be used for new device /// tokens and for existing tokens. If a token has become inactive reregistering it will make it active again. /// </summary> /// <returns>Service Response</returns> /// <exception cref="ArgumentException">A device Tokens Token field is Required</exception> public BaseResponse RegisterDeviceToken(DeviceToken deviceToken) { if (string.IsNullOrEmpty(deviceToken.Token)) { throw new ArgumentException("A device Tokens Token field is Required", "deviceToken"); } return(SendRequest(new DeviceTokenRequest(deviceToken))); }
public void Should_Construct_DeviceToken() { DeviceToken deviceToken = new DeviceToken(userProfileId, deviceTokenValue, deviceVersion, deviceName, model, userDeviceId, timeStamp, sourceIP, android); _ = new DeviceToken(); _ = deviceToken.DeviceId; _ = deviceToken.UserProfile; deviceToken.ShouldNotBeNull(); }
public Authenticator() { m_deviceToken = new DeviceToken(); if (m_user == null) { m_user = new User(); m_user.Load(); m_user.saveID = m_deviceToken.deviceToken; m_user.Save(); } }
/// <summary> /// Validates this instance. /// </summary> /// <remarks> /// <para>Ensures <seealso cref="DeviceToken"/> and <see cref="PosVendor"/> are not null, empty strings or contain only whitespace. Also ensures they are not longer than allowed.</para> /// <para>Also ensures all base properties are valid, see <see cref="RequestBase.Validate"/>.</para> /// </remarks> public override void Validate() { DeviceToken.GuardNullOrWhiteSpace("request", nameof(DeviceToken)); DeviceToken.GuardLength("request", nameof(DeviceToken), 64); PosVendor.GuardNullOrWhiteSpace("request", nameof(PosVendor)); PosVendor.GuardLength("request", nameof(PosVendor), 100); base.Validate(); }
private bool getAPIToken() { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(_sfAPIServiceTokenEndPoint); request.Method = "POST"; HttpWebResponse response = null; string postData = "grant_type=password&email=" + _email + "&password="******"&role=device"; byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { using (StreamReader sr = new StreamReader(response.GetResponseStream())) { _currentDeviceToken = JsonConvert.DeserializeObject <DeviceToken>(sr.ReadToEnd()); } if (!string.IsNullOrEmpty(_currentDeviceToken.access_token)) { StringBuilder logMessage = new StringBuilder(); logMessage.AppendLine("audit: User Login Successful."); //logMessage.AppendLine("accessToken:" + currentDeviceToken.access_token); //logMessage.AppendLine("tokenType:" + currentDeviceToken.token_type); Logger.showDebug(TAG, logMessage); return(true); } return(false); } else { if (response.StatusCode == HttpStatusCode.BadRequest || response.StatusCode == HttpStatusCode.Unauthorized) { throw new Exception("Authentication Fail"); } else { StringBuilder logMessage = new StringBuilder(); logMessage.AppendLine("Failed to get API Token."); logMessage.AppendLine("Url: " + _sfAPIServiceBaseURI); logMessage.AppendLine("Device ID: " + _email); logMessage.AppendLine("Device Password: " + _password); Logger.showDebug(TAG, logMessage); throw new Exception(logMessage.ToString()); } } }
public IActionResult UpdateUserDevice([FromBody, BindRequired] UpdateDeviceToken body) { var user = this.DomainUser(); registry.UpdateToken( user.Id, DeviceId.From(body.DeviceId), DeviceToken.From(body.Token) ); return(NoContent()); }
public HttpResponseMessage Post(DeviceToken deviceToken) { var response = Request.CreateResponse<DeviceToken>(System.Net.HttpStatusCode.Found, deviceToken); if (!db.DeviceTokens.Any(x => x.Token == deviceToken.Token)) { db.DeviceTokens.InsertOnSubmit(deviceToken); db.SubmitChanges(); response = Request.CreateResponse<DeviceToken>(System.Net.HttpStatusCode.Created, deviceToken); } return response; }
public void FromBinary_should_return_correct_token() { // Arrange var tokenBytes = new byte[] { 0xfe, 0x58, 0xfc, 0x8f, 0x52, 0x7c, 0x36, 0x3d, 0x1b, 0x77, 0x5d, 0xca, 0x13, 0x3e, 0x04, 0xbf, 0xf2, 0x4d, 0xc5, 0x03, 0x2d, 0x08, 0x83, 0x69, 0x92, 0x39, 0x5c, 0xc5, 0x6b, 0xfa, 0x62, 0xef }; // Act var token = DeviceToken.FromBinary(tokenBytes); // Assert Assert.AreEqual("fe58fc8f527c363d1b775dca133e04bff24dc5032d08836992395cc56bfa62ef", token.ToString()); }
public byte[] ToBytes() { byte[] deviceToken = new byte[DeviceToken.Length / 2]; for (int i = 0; i < deviceToken.Length; i++) { deviceToken[i] = byte.Parse(DeviceToken.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber); } if (deviceToken.Length != DEVICE_TOKEN_BINARY_SIZE) { throw new BadDeviceTokenException(DeviceToken); } byte[] deviceTokenSize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Convert.ToInt16(deviceToken.Length))); byte[] payload = Encoding.UTF8.GetBytes(Payload.ToJson()); if (payload.Length > MAX_PAYLOAD_SIZE) { int newSize = Payload.Alert.Body.Length - (payload.Length - MAX_PAYLOAD_SIZE); if (newSize > 0) { Payload.Alert.Body = Payload.Alert.Body.Substring(0, newSize); payload = Encoding.UTF8.GetBytes(Payload.ToString()); } else { do { Payload.Alert.Body = Payload.Alert.Body.Remove(Payload.Alert.Body.Length - 1); payload = Encoding.UTF8.GetBytes(Payload.ToString()); }while (payload.Length > MAX_PAYLOAD_SIZE && !string.IsNullOrEmpty(Payload.Alert.Body)); } if (payload.Length > MAX_PAYLOAD_SIZE) { throw new NotificationLengthException(this); } } byte[] payloadSize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Convert.ToInt16(payload.Length))); int bufferSize = sizeof(Byte) + deviceTokenSize.Length + deviceToken.Length + payloadSize.Length + payload.Length; byte[] buffer = new byte[bufferSize]; buffer[0] = 0x00; Buffer.BlockCopy(deviceTokenSize, 0, buffer, sizeof(Byte), deviceTokenSize.Length); Buffer.BlockCopy(deviceToken, 0, buffer, sizeof(Byte) + deviceTokenSize.Length, deviceToken.Length); Buffer.BlockCopy(payloadSize, 0, buffer, sizeof(Byte) + deviceTokenSize.Length + deviceToken.Length, payloadSize.Length); Buffer.BlockCopy(payload, 0, buffer, sizeof(Byte) + deviceTokenSize.Length + deviceToken.Length + payloadSize.Length, payload.Length); return(buffer); }
public async Task GetAsync([FromQuery(Name = "tk")] string token) { this._logger.LogInformation("WsControllerGetAsyncCallBeingMade"); this._token = token; if (this.HttpContext.WebSockets.IsWebSocketRequest) { // get the user with this token and set the IsDeviceOnline to true DeviceToken devTok = this._context.DeviceTokens .Include(dt => dt.User).FirstOrDefault(dt => dt.Token == token); this._context.SaveChanges(); this._logger.LogInformation("WsControllerGetAsync" + this._token + "::" + token); var buffer = new byte[1024 * 4]; this._webSocket = await this.HttpContext.WebSockets.AcceptWebSocketAsync(); this._logger.LogInformation("WsControllerGetAsyncProtocol" + this._token + "::" + this.HttpContext.WebSockets.WebSocketRequestedProtocols); try { devTok.IsDeviceOnline = true; devTok.DeviceEvents.Add(new DeviceEvent(DateTime.UtcNow, true)); while (this._webSocket != null && this._webSocket.State == WebSocketState.Open) { WebSocketReceiveResult response = await _webSocket.ReceiveAsync(new ArraySegment <byte>(buffer), CancellationToken.None); if (response.MessageType == WebSocketMessageType.Close) { break; } } this._pushNotificationService.BroadcastDeviceOfflineNotification(devTok.User, devTok.Token); devTok.IsDeviceOnline = false; devTok.DeviceEvents.Add(new DeviceEvent(DateTime.UtcNow, false)); this._context.SaveChanges(); await _webSocket.CloseAsync(WebSocketCloseStatus.Empty, "Closed_by_client", CancellationToken.None); } catch (WebSocketException ex) { this._logger.LogError("WsControllerGetAsync:Error::" + ex.Message); switch (ex.WebSocketErrorCode) { case WebSocketError.ConnectionClosedPrematurely: this._pushNotificationService.BroadcastDeviceOfflineNotification(devTok.User, devTok.Token); devTok.IsDeviceOnline = false; devTok.DeviceEvents.Add(new DeviceEvent(DateTime.UtcNow, false)); this._context.SaveChanges(); break; default: break; } } } }
/// <summary> /// Registers a device token with extended properties with the Urban Airship site, this can be used for new device /// tokens and for existing tokens. If a token has become inactive reregistering it will make it active again. /// </summary> /// <returns>Response from Urban Airship</returns> public BaseResponse RegisterDeviceToken(DeviceToken deviceToken) { if (string.IsNullOrEmpty(deviceToken.Token)) { throw new ArgumentException("A device Tokens Token field is Required", "deviceToken"); } var deviceRequest = new DeviceTokenRequest(deviceToken); var requestTask = deviceRequest.ExecuteAsync(); return(requestTask.Result); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (DeviceToken.IsNullOrEmpty() || UserId == 0) { //yield return new ValidationResult("设备编号与用户编号为必传!", new string[] { "UserId", "DeviceToken" }); yield return(new ValidationResult("服务器开小差啦,请重试!")); } if (UserId == 0 && !DeviceToken.IsNullOrEmpty() && DeviceToken.Length < 10) { yield return(new ValidationResult("服务器开小差啦,请重试!")); } }
/** * Get device by token and change state */ private string DeviceState(string token, string state) { object response; DeviceToken dbToken = DeviceToken.GetToken(token); if (dbToken != null) { Device dbDevice = Device.GetDevice(dbToken); if (dbDevice != null) { var chageState = true; switch (state) { case "lock": dbDevice.Locked = true; break; case "unlock": dbDevice.Locked = false; break; default: chageState = false; break; } if (chageState) { dbDevice = Device.ChangeLock(dbDevice); } response = dbDevice; } else { response = new ResponseError("Device not found!"); } } else { response = new ResponseError("Token not found!"); } var serializeOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true }; return(JsonSerializer.Serialize(response, serializeOptions)); }
public bool SendFCM(string message, string subject, int UserID) { try { Dictionary <Extensions.SystemInfo, string> settings = GetSystemSettings; string applicationID = Decrypt(settings[Extensions.SystemInfo.FcmApplicationID]); string senderId = Decrypt(settings[Extensions.SystemInfo.FcmSenderID]); //SaveTxtLog("ApplicationID:" + applicationID); //SaveTxtLog("senderId:" + senderId); DeviceToken device = db.DeviceTokens.Where((DeviceToken d) => d.UserID == UserID).FirstOrDefault(); string deviceId = ""; deviceId = ((device == null) ? "49af1e67bb8e8306ae2cb3cf60c76a46646210be" : device.DeviceToken1); SaveTxtLog($"UserID: {UserID} , DeviceToken:{deviceId}"); WebRequest tRequest = WebRequest.Create(settings[Extensions.SystemInfo.FcmAddress]); tRequest.Method = "post"; tRequest.ContentType = "application/json"; List <string> dest = new List <string>(); dest.Add(deviceId); var data = new { to = deviceId, notification = new { body = message, title = subject, icon = "myicon", sound = "default" }, priority = "high" }; string output = ""; output = JsonConvert.SerializeObject(data); byte[] byteArray = Encoding.UTF8.GetBytes(output); tRequest.Headers.Add($"Authorization: key={applicationID}"); tRequest.Headers.Add($"Sender: id={senderId}"); tRequest.ContentLength = byteArray.Length; Stream dataStream = tRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); WebResponse tResponse = tRequest.GetResponse(); Stream dataStreamResponse = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStreamResponse); string sResponseFromServer = tReader.ReadToEnd(); SaveTxtLog("Response from FCM:" + sResponseFromServer); return(true); } catch (Exception ex) { SaveTxtLog(ex.ToString()); return(false); } }
public void ToBytes_should_return_correct_bytes() { // Arrange var token = new DeviceToken("fe58fc8f527c363d1b775dca133e04bff24dc5032d08836992395cc56bfa62ef"); var realTokenBytes = new byte[] { 0xfe, 0x58, 0xfc, 0x8f, 0x52, 0x7c, 0x36, 0x3d, 0x1b, 0x77, 0x5d, 0xca, 0x13, 0x3e, 0x04, 0xbf, 0xf2, 0x4d, 0xc5, 0x03, 0x2d, 0x08, 0x83, 0x69, 0x92, 0x39, 0x5c, 0xc5, 0x6b, 0xfa, 0x62, 0xef }; // Act var tokenBytes = token.ToByteArray(); // Assert Assert.AreEqual(32, tokenBytes.Length); Assert.AreEqual(tokenBytes, realTokenBytes); }
public async void EmailVerification() { try { DeviceToken Dt = new DeviceToken(); if (CurrentUser.GetId() != null) { Dt = await svc.VerifyMail(CurrentUser.GetId()); } if (Dt.VerificationStatus == 1) { CurrentUser.Store(cr.customer.CustomerID.ToString(), cr.customer.FirstName + cr.customer.LastName); CurrentUser.PutStore(cr.customer.PreferredStore); if (RootTabs == null || _window == null) { RootTabs = CurrentUser.RootTabs; _window = CurrentUser.window; nav = new UINavigationController(RootTabs); AddNavigationButtons(nav); _window.RootViewController = nav; LoggingClass.LogInfo("The User logged in with user id: " + CurrentUser.RetreiveUserId(), screenid); } else { nav = new UINavigationController(RootTabs); AddNavigationButtons(nav); _window.RootViewController = nav; LoggingClass.LogInfo("The User logged in with user id: " + CurrentUser.RetreiveUserId(), screenid); } BTProgressHUD.Dismiss(); } else { try { BTProgressHUD.ShowErrorWithStatus("Your email is not verified plesase check email and verify.", 5000); View.AddSubview(btnResend); } catch (Exception ex) { LoggingClass.LogError(ex.Message, screenid, ex.StackTrace); } } } catch (Exception Exe) { LoggingClass.LogError(Exe.Message, screenid, Exe.StackTrace); } }
public void ToBytes_should_return_correct_bytes() { // Arrange var token = new DeviceToken("fe58fc8f527c363d1b775dca133e04bff24dc5032d08836992395cc56bfa62ef"); var realTokenBytes = new byte[] { 0xfe, 0x58, 0xfc, 0x8f, 0x52, 0x7c, 0x36, 0x3d, 0x1b,0x77,0x5d,0xca,0x13,0x3e,0x04,0xbf,0xf2,0x4d,0xc5,0x03,0x2d,0x08,0x83,0x69,0x92,0x39,0x5c,0xc5,0x6b,0xfa,0x62,0xef }; // Act var tokenBytes = token.ToByteArray(); // Assert Assert.AreEqual(32, tokenBytes.Length); Assert.AreEqual(tokenBytes, realTokenBytes); }
public void InsertDeviceToken(string playerId, string pushToken) { try { connection.DeleteAll <DeviceToken>(); var device = new DeviceToken(); device.Id = 1; device.PlayerId = playerId; device.PushToken = pushToken; connection.Insert(device); } catch (Exception ex) { } }
public void ToByteArray_should_return_correct_bytes() { // Arrange var token = new DeviceToken(Guid.NewGuid().ToString().Replace("-", string.Empty) + Guid.NewGuid().ToString().Replace("-", string.Empty)); var payload = new Payload(new PayloadAlertMessage("test"), 1, "sound.wav"); var simpleNotification = new SimpleNotification(token, payload); // Act var result = simpleNotification.ToByteArray(); // Assert Assert.AreEqual(0, result[0]); Assert.AreEqual(0, result[1]); Assert.AreEqual(0x20, result[2]); Assert.AreEqual(0x00, result[35]); Assert.AreEqual(payload.ToJson().Length, result[36]); }
public SimpleNotification(DeviceToken token, IPayload payload) { this.deviceToken = token; this.payload = payload; }
public void Constructor_should_validate_token() { var token = new DeviceToken("testing-with weird. symbols;"); }
public FeedbackTuple(DateTime timeStamp, DeviceToken deviceToken) { this.TimeStamp = timeStamp; this.DeviceToken = deviceToken; }