【发布时间】:2017-02-20 00:53:57
【问题描述】:
我有以下设置,当我在 iPhone 7 中使用 url 打开我的应用程序(应用程序号 2 由应用程序号 1 使用 url 打开)时,我没有收到任何 url 输入。
它根本没有显示任何警报框。 我如何检查我是否在我的应用程序中收到了 url 输入?
AppDelegate.m:
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
ViewController.m:
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
//if (url != nil && [url isFileURL]) {
//[self.ViewController handleOpenURL:url];
//}
id test = (NSURL *) url;
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"My Title"
message:test
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
//NSLog(@">>> got <<< >>> <<< !!!! >>>> : %@", url);
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
}
【问题讨论】:
标签: ios objective-c iphone url-scheme