0
FCM注册令牌需要10秒刷新,并且它非常不受欢迎。我如何能够立即生效。我是按照FCM Docs生成的。是否有办法立即生成FCM令牌?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:) name:kFIRInstanceIDTokenRefreshNotification object:nil];
}
然后,
- (void)tokenRefreshNotification:(NSNotification *)notification {
NSString *refreshedToken = [[FIRInstanceID instanceID] token];
NSLog(@"InstanceID token: %@", refreshedToken);
// Connect to FCM since connection may have failed when attempted before having a token.
[self connectToFcm];
}
,我使用FirebaseAppDelegateProxyEnabled。
在此先感谢
考虑使其成为一个异步过程,因此用户可以在不需要等待的情况下继续进行应用程序。那么在收到令牌后,您可以相应地处理它(即通过API发送到后端) – jokerday