配置好Universal link后
第一步
AppDelegate 中
@property (strong, nonatomic) NSString *jumpUrl;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *activityDictionary = launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
if (activityDictionary) {
NSUserActivity *activity = [activityDictionary objectForKey:@"UIApplicationLaunchOptionsUserActivityKey"];
NSString *urlString = activity.webpageURL.absoluteString;
NSURL *url = [NSURL URLWithString:urlString];
NSString *str = [NSString stringWithFormat:@"%@",url];
self.jumpUrl =str;
return YES;
}
第二步
首页中取jumpUrl进行接下来的操作
- (void)viewDidLoad {
[super viewDidLoad];
AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;
NSString *url=app.jumpUrl;
}