与其他非越狱应用程序一样,我需要在用theos编写的调整应用程序中定义URL方案,但是它不起作用,有人有想法吗? 我已经建立了一个纯净的项目来对此进行测试,有人可以帮忙吗?非常感谢。 https://github.com/kentkrantz/testurlscheme
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.yourcompany.testurlscheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>testus</string>
</array>
</dict>
</array>
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
// if (!url) {
// return NO;
// }
NSLog(@">>>>>>>>>>>> 11111");
NSLog(@"url recieved: %@", url);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
NSLog(@"url path: %@", [url path]);
NSDictionary *dict = [self parseQueryString:[url query]];
NSLog(@"query dict: %@", dict);
return YES;
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
NSLog(@">>>>>>>>>>>> 22222");
NSLog(@"url recieved: %@", url);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
NSLog(@"url path: %@", [url path]);
NSDictionary *dict = [self parseQueryString:[url query]];
NSLog(@"query dict: %@", dict);
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@">>>>>>>>>>>> 33333");
NSLog(@"url recieved: %@", url);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
NSLog(@"url path: %@", [url path]);
NSDictionary *dict = [self parseQueryString:[url query]];
NSLog(@"query dict: %@", dict);
return YES;
}
- (NSDictionary *)parseQueryString:(NSString *)query
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:6];
NSArray *pairs = [query componentsSeparatedByString:@"&"];
for (NSString *pair in pairs) {
NSArray *elements = [pair componentsSeparatedByString:@"="];
NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[dict setObject:val forKey:key];
}
return dict;
}