xamarin - Registering for remote notifications fails silently -


i trying implement push notifications our xamarin.ios app. i've followed multiple getting started guides , other tutorials, can't seem device token more. has worked before, , nothing significant changed, can't seem pinpoint problem here.

appdelegate.cs

[register("appdelegate")] public class appdelegate : uiapplicationdelegate, ireceiverdelegate {     public override bool finishedlaunching(uiapplication application, nsdictionary launchoptions)     {         var gcmconfig = google.googlecloudmessaging.config.defaultconfig;         gcmconfig.receiverdelegate = this;         google.googlecloudmessaging.service.sharedinstance.start(gcmconfig);          var nottypes = uiusernotificationtype.sound | uiusernotificationtype.alert | uiusernotificationtype.badge;         var settings = uiusernotificationsettings.getsettingsfortypes(nottypes, null);         uiapplication.sharedapplication.registerusernotificationsettings(settings);         uiapplication.sharedapplication.registerforremotenotifications();          // ... other application stuff          return true;     }      public override void onactivated(uiapplication application)     {         google.googlecloudmessaging.service.sharedinstance.connect(error =>         {             if (error != null)             {                 console.writeline("gcm connect error: " + error);             }         });     }      public override void didenterbackground(uiapplication application)     {         google.googlecloudmessaging.service.sharedinstance.disconnect();     }      private nsdata devicetoken;     // function not called anymore     public override void registeredforremotenotifications(uiapplication application, nsdata devicetoken)     {         this.devicetoken = devicetoken;          var config = google.instanceid.config.defaultconfig;         google.instanceid.instanceid.sharedinstance.start(config);          var options = new nsmutabledictionary();         options.setvalueforkey(devicetoken, google.instanceid.constants.registerapnsoption);         options.setvalueforkey(new nsnumber(true), google.instanceid.constants.apnsservertypesandboxoption);          google.instanceid.instanceid.sharedinstance.token(             gcmconnection.senderid,             google.instanceid.constants.scopegcm,             options,             (token, error) => {                 if (error == null)                 {                     // ... send token our api                      pubsub.sharedinstance.subscribe(token, "/topics/global", new nsdictionary(), delegate { });                     return;                 }                 console.writeline("error getting gcm token: " + error);                 // handle error         });     }      public override void failedtoregisterforremotenotifications(uiapplication application, nserror error)     {         console.writeline(error);     }      public override void didreceiveremotenotification(uiapplication application, nsdictionary userinfo, action<uibackgroundfetchresult> completionhandler)     {         // handle notification here         google.googlecloudmessaging.service.sharedinstance.appdidreceivemessage(userinfo);     }       [export("diddeletemessagesonserver")]     public void diddeletemessagesonserver()     {         // ...     }      [export("didsenddatamessagewithid:")]     public void didsenddatamessage(string messageid)     {         // ...     }      [export("willsenddatamessagewithid:error:")]     public void willsenddatamessage(string messageid, nserror error)     {         // ...     } } 

i've shortened code on points brevity.

at point yesterday, getting tokens , recieve of notifications supposed get. without changing finishedlaunching method, stopped working, without feedback why.

when tried fix it, noticed errors in console.log related gcm, i've since fixed (for example, forgot googleservice-info.plist file), point no errors shown in console.

i've read multiple times clean+rebuild project/solution, i've done couple of times now, no avail.

i truely clueless should continue for.

i had same issue yesterday. today tried again without changes code , worked. spent 5 hours in issue , searched apple developer sites check if there problems apple services , didn't find anything. absolutely annoying!

in end seemed apple-caused error has been solved today.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -