冷启动唤醒后进行操作无效,其实是控制器还未创建完成,给通知添加延时即可。
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
NSString*urlStr = url.absoluteString;
BOOL ret = [urlStr hasPrefix:@"dxylink://joinCourse"];
if(ret){
NSLog(@"url query:%@",[url query]);
NSArray *paramsArray = [[url query] componentsSeparatedByString:@"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for(NSString*paraminparamsArray){
NSArray*curParams = [paramcomponentsSeparatedByString:@"="];
[paramssetValue:[curParamslastObject]forKey:[curParamsfirstObject]];
}
NSArray*arr = [NSArrayarrayWithArray:params.allValues];
self.codeStr= arr.firstObject;
[self performSelector:@selector(postNoti) withObject:nil afterDelay:1];
NSLog(@"url scheme params:%@",params);
}
return YES;
}
- (void)postNoti {
[[NSNotificationCenter defaultCenter] postNotificationName:@"LinkNoti" object:nil userInfo:@{@"str":self.codeStr}];
}