Xamarin Android GCM instanceID.GetToken 抛出超时异常

Xamarin Android GCM instanceID.GetToken throws TIMEOUT Exception

我对 xamarin gcm 实施有疑问

这是我的代码示例

var instanceID = InstanceID.GetInstance(context.ApplicationContext);
token = instanceID.GetToken("MYSENDERID", GoogleCloudMessaging.InstanceIdScope, null);

它正在另一个线程上工作(不是主线程) instanceID.GetToken 抛出错误(我给了所有权限)

错误:

Java.IO.IOException: TIMEOUT
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00064] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.

我修好了。

原因是我忘了创建服务。它仅适用于服务