public async Task RegisterDevice(NSData deviceToken) { var DeviceToken = deviceToken.Description; if (!string.IsNullOrWhiteSpace(DeviceToken)) { DeviceToken = DeviceToken.Trim('<').Trim('>'); } LocalData ld = new LocalData (); DeviceRegistration dr = ld.GetDeviceRegistration (); bool needNewRegistration = false; if (dr != null) { dr = ld.GetDeviceRegistration (); //update registration DeviceRegistrationDTO drtoo = new DeviceRegistrationDTO () { Platform = dr.Platform, Handle = dr.Handle, Tags = dr.Tags.Split('|'), RegistrationId = dr.RegistrationId }; string result = await client.InvokeApiAsync<DeviceRegistrationDTO,string> ("NotificationCustom/RegistrationUpdate/", drtoo); if (result == "gone") { needNewRegistration = true; ld.DeleteDeviceRegistration (); } } if (dr == null || needNewRegistration) { //get token string token = await client.InvokeApiAsync<string,string> ("NotificationCustom/RegistrationCreate/", " "); DeviceRegistrationDTO drto = new DeviceRegistrationDTO () { Platform = "apns", Handle = DeviceToken, Tags = new string[]{ "ios_users", "all_users", "userid_" + CurrentUser.Id, "areacode_" + CurrentUser.AreaCode }, RegistrationId = token }; //update registration string result = await client.InvokeApiAsync<DeviceRegistrationDTO, string> ("NotificationCustom/RegistrationUpdate/", drto); ld.InsertDeviceRegistration (dr); } }