【问题标题】:how to open instagram app on button click如何在按钮单击时打开 Instagram 应用程序
【发布时间】:2016-08-06 11:32:42
【问题描述】:
  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:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[[assetURL absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding],caption]];

标签: ios instagram


【解决方案1】:

您可以通过用户名打开 Instagram 应用程序,

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

更多关于api的方法和细节可以参考iPhone Hooks of Instagram!!!

更新:

替换下一行,

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

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

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

【讨论】:

  • 你好 ketan,但我的应用程序通常不需要登录,如果用户在我的应用程序中点击 instagram 按钮,应用程序应该打开,但我仍然努力修复它如何在没有登录的情况下打开,我没有写这个方法中的任何东西
  • -(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options{ return YES; }
  • 是的,我确实尝试过,我认为我做了同样的事情,但仍然对我有用,而且正常情况下,执行此任务的步骤是什么 plist 应该是什么以及要覆盖的区域是什么工作完成
【解决方案2】:

在 Info.plist 文件中添加键值

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
        <string>twitter</string>
    </array>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-28
    • 2015-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多