【问题标题】:Shared link that will open my app or the app store将打开我的应用或应用商店的共享链接
【发布时间】:2014-06-26 10:59:11
【问题描述】:

我已经开始开发一个 iPhone 应用程序,我决定希望用户能够在网络上分享它的内容(通过电子邮件、Facebook、Twitter、消息等......)。现在我希望应用程序的链接(在用户的共享帖子上)能够检查我的应用程序是否安装在设备上并通过它的 URL 方案打开它,如果不是 - 打开另一个链接到应用程序在 App Store 上。

我已经做了一些研究并且明白我应该在我的服务器端制作一个 php 或类似的东西,但是我找不到一个教程或一个清晰的傻瓜示例(我对 php/jscript/ 一无所知jquery)...有人可以帮我看看吗?

【问题讨论】:

    标签: php jquery html ios app-store


    【解决方案1】:
    - (IBAction)openOtherAppButtonAction
    {
        UIApplication *ourApplication = [UIApplication sharedApplication];
        NSString *URLEncodedText = [@"AppName" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSString *ourPath = [@"openapp://" stringByAppendingString:URLEncodedText];   //openapp is the url custom scheme name.
        NSURL *ourURL = [NSURL URLWithString:ourPath];                              //instead of our path you can directly write @"openapp"
    
         if ([ourApplication canOpenURL:ourURL]) 
             [ourApplication openURL:ourURL];
        else 
        {
            //Display error
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Receiver Not Found" message:@"The Receiver App is not installed." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
     // OR open link
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.urlForApp.com"]];
        }
    }
    

    // 现在你要打开哪个应用去它的info.plist

    1 添加一个名称为 ----> URL 类型的新行

    2 现在在第 0 项中添加另一个名为 ------> URL Schemes 的对象

    3 现在,在 URL Schemes 的第 0 项中,给出您想要打开应用程序的名称,例如 @"openapp"

    4 你必须在你要打开的应用程序的应用程序委托中写这个

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url    {    return YES;    }
    

    【讨论】:

    • 首先非常感谢您的回复。虽然这是一个很好的解决方案,但它不是我正在寻找的功能。我希望链接出现在 Facebook 帖子中,然后从那里进行链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 2018-12-06
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    相关资源
    最近更新 更多