如何在按钮上单击打开instagram应用程序 [英] how to open instagram app on button click

查看:354
本文介绍了如何在按钮上单击打开instagram应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 大家好,我都想在单击按钮时打开instagram应用,但不是 能够在plist中将Url方案设置为instagram

    NSString *instagramURL = @"instagram://app"; 
    NSURL *ourURL = [NSURLURLWithString:instagramURL]; 
    if ([[UIApplication sharedApplication]canOpenURL:ourURL]) {
        [[UIApplication sharedApplication]openURL:ourURL];
    
    } else {
        //The App is not installed. It must be installed from iTunes code.
        NSString *iTunesLink = @"//Some other Url goes here";
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
    
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"URL error"
              message:[NSString stringWithFormat: @"No custom URL defined for %@", ourURL]
              delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
    

    我确实喜欢这样,但是应用未对iOS全新开放,可以提供任何帮助 赞赏

解决方案

您可以按用户名打开instagram应用,

 NSURL *instagramURL = [NSURL URLWithString:@"instagram://user?username=USERNAME"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [[UIApplication sharedApplication] openURL:instagramURL];
}

您可以参考 Instagram的iPhone挂钩,以了解更多方法和信息关于api的详细信息!!!

更新:

替换行下方

 NSString *instagramURL = @"instagram://app"; 

使用

   NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];

您直接将字符串分配为url !!

  1. Hi all am trying to open instagram app on a button click but am not able to i set Url scheme as instagram in plist also

    NSString *instagramURL = @"instagram://app"; 
    NSURL *ourURL = [NSURLURLWithString:instagramURL]; 
    if ([[UIApplication sharedApplication]canOpenURL:ourURL]) {
        [[UIApplication sharedApplication]openURL:ourURL];
    
    } else {
        //The App is not installed. It must be installed from iTunes code.
        NSString *iTunesLink = @"//Some other Url goes here";
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
    
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"URL error"
              message:[NSString stringWithFormat: @"No custom URL defined for %@", ourURL]
              delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
    

    i did like this but app not opening am new to iOS any help can be appreciated

解决方案

You can open instagram app by username like,

 NSURL *instagramURL = [NSURL URLWithString:@"instagram://user?username=USERNAME"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [[UIApplication sharedApplication] openURL:instagramURL];
}

You can refer iPhone Hooks of Instagram for more ways and details about api!!!

Update :

Replace below line,

 NSString *instagramURL = @"instagram://app"; 

with

   NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];

You are assigning directly string as url!!

这篇关于如何在按钮上单击打开instagram应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆