美文网首页
Ios 打开第三方应用传值

Ios 打开第三方应用传值

作者: 透支未来 | 来源:发表于2017-06-07 19:08 被阅读30次
    
    #pragma mark 设置系统回调
    // 支持所有iOS系统
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
    
       NSLog(@"%@", url);
        
        if ([[url scheme] isEqualToString:@"myurltest"])
        {
            //处理链接
            NSString *text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"新消息" message:text delegate:self cancelButtonTitle:@"知道了" otherButtonTitles: nil];
            [myAlert show];
            
            return YES;
        }
        
        return NO;
    }
    
    //仅支持iOS9以上系统,iOS8及以下系统不会回调
    - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
    {
    NSLog(@"%@", url);
        
        if ([[url scheme] isEqualToString:@"myurltest"])
        {
            //处理链接
            NSString *text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"新消息" message:text delegate:self cancelButtonTitle:@"知道了" otherButtonTitles: nil];
            [myAlert show];
            
            return YES;
        }
        
        return NO;
    }
    //支持目前所有iOS系统
    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
    {
       NSLog(@"%@", url);
        
        if ([[url scheme] isEqualToString:@"myurltest"])
        {
            //处理链接
            NSString *text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"新消息" message:text delegate:self cancelButtonTitle:@"知道了" otherButtonTitles: nil];
            [myAlert show];
            
            return YES;
        }
        
        return NO;
    }
    

    相关文章

      网友评论

          本文标题:Ios 打开第三方应用传值

          本文链接:https://www.haomeiwen.com/subject/pgsafxtx.html