//Fires when device is unregistered public void OnUnregistered(PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine("Push Notification - Device Unnregistered"); //Remove Token from Server var tokenObject = new Token { TokenID = Application.Current.Properties["Token"].ToString(), Type = "U" }; var content1 = JsonConvert.SerializeObject(tokenObject); var content2 = new StringContent(content1, Encoding.UTF8, "application/json"); var response = _client.PostAsync(_url + "UnRegisterToken/", content2).Result; if (!response.IsSuccessStatusCode) { MessagingCenter.Send(this, "DisplayMsg", "Token removed from Server unsuccessfully"); } //else //remove token regardless, otherwise the user wont be registered again //{ Application.Current.Properties["Token"] = ""; MessagingCenter.Send(this, "DisplayMsg", "Device has been unregistered successfully"); Application.Current.SavePropertiesAsync(); //} }
public void OnMessage(JObject values, PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine($"Message Arrived: {values.ToString()}"); if (deviceType == PushNotification.Plugin.Abstractions.DeviceType.Android) { var p = JObject.Parse(values.ToString()); if (p != null && p["info"] != null && p["info"].ToString() == "blotter") { Global.ReceivedCrimeAlert = true; MessagingCenter.Send <object, string>(Global.MessagingInstance, "Notification", p["text"].ToString()); } } if (deviceType == PushNotification.Plugin.Abstractions.DeviceType.iOS) { var p = JObject.Parse(values.ToString()); if (p != null && p["alert"] != null) { Global.ReceivedCrimeAlert = true; MessagingCenter.Send <object, string>(Global.MessagingInstance, "Notification", p["alert"].ToString()); } } }
//Gets the registration token after push registration public void OnRegistered(string token, PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine(string.Format("Push Notification - Device Registered - Token : {0}", token)); //Send Token to Server var tokenObject = new Token { TokenID = token, Type = "U", User = Application.Current.Properties["Username"].ToString() }; var content1 = JsonConvert.SerializeObject(tokenObject); var content2 = new StringContent(content1, Encoding.UTF8, "application/json"); var response = _client.PostAsync(_url + "RegisterToken/", content2).Result; if (!response.IsSuccessStatusCode) { MessagingCenter.Send(this, "DisplayMsg", "Token sent to Server unsuccessfully"); Application.Current.Properties["Token"] = ""; } else { Application.Current.Properties["Token"] = token; MessagingCenter.Send(this, "DisplayMsg", "Device has been registered successfully"); } Application.Current.SavePropertiesAsync(); }
public void OnUnregistered(PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine("Push Notification - Device Unnregistered"); }
public void OnRegistered(string token, PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine(string.Format("Push Notification - Device Registered - Token : {0}", token)); Location.PostToken(token, deviceType); }
public void OnError(string message, PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine(string.Format("Push notification error - {0}", message)); }
//Fires when error public void OnError(string message, PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine(string.Format("Push notification error - {0}", message)); MessagingCenter.Send(this, "DisplayMsg", string.Format("Push notification error - {0}", message)); }
//Here you will receive all push notification messages //Messages arrives as a dictionary, the device type is also sent in order to check specific keys correctly depending on the platform. public void OnMessage(JObject values, PushNotification.Plugin.Abstractions.DeviceType deviceType) { Debug.WriteLine("Message Arrived"); }
public void OnError(string message, PushNotification.Plugin.Abstractions.DeviceType deviceType) { AppProvider.Log.WriteLine(LogChannel.Notifications, "OnError: {0} / {1}", message, deviceType); }
public void OnUnregistered(PushNotification.Plugin.Abstractions.DeviceType deviceType) { AppProvider.Log.WriteLine(LogChannel.Notifications, "UnRegister: {0}", deviceType); }
public void OnMessage(System.Collections.Generic.IDictionary <string, object> Parameters, PushNotification.Plugin.Abstractions.DeviceType deviceType) { AppProvider.Log.WriteLine(LogChannel.Notifications, "OnMessage: {0} / {1}", Parameters, deviceType); }