Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override async void OnResume()
- {
- //Helpers.Settings is James's Settings plugin, this setting with the replaces works in other parts so i have no reason
- //to assume this is the cause
- var req = new RegistrationUpdate()
- {
- SerialKey = Helpers.Settings.License.Replace("/", "").Replace("\\", "").Replace('"', ' ').Trim()
- };
- var stringc = new StringContent(JsonConvert.SerializeObject(req), Encoding.UTF8, "application/json");
- //Just a manager that uses a httpclient to stick getKey behind our API's URL and make a post request with the stringcontent
- //as the post body
- var res = await RestManager.Instance.ExecuteRest("getKey", stringc);
- //Null if the api is down or if there is an error on the api's side, manager reports this to another api call that saves
- //the api response/ stacktrace, offline is when the user doesnt have connection.
- if (res != null && res != "offline")
- {
- //So here Res is Not NULL and Not Offline, so the null reference cant happen here.
- var resm = JsonConvert.DeserializeObject<RegistrationKey>(res);
- //Another check JIC also references crossfirebase but would be weird if this is the case.
- if (resm.RegToken == "" || resm.RegToken != CrossFirebasePushNotification.Current.Token)
- {
- //More of the same, create a request to send to the api
- var request = new RegistrationUpdate()
- {
- RegToken = CrossFirebasePushNotification.Current.Token,
- SerialKey = Helpers.Settings.License.Replace("/", "").Replace("\\", "").Replace('"', ' ').Trim()
- };
- try
- {
- //Stuck this in a try catch to see if this part was the cause, since it would just continue on and not crash.
- //But the crash still happens so this part isnt the cause
- var stringContent = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
- await RestManager.Instance.ExecuteRest("SetPushtoken", stringContent);
- }
- catch
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement