php - 将打开我的应用程序或应用程序商店的共享链接

标签 php jquery html ios app-store

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

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

最佳答案

- (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 你必须在你想打开的应用程序的应用程序委托(delegate)中写这个

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

关于php - 将打开我的应用程序或应用程序商店的共享链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24428697/

相关文章:

php - 在 PHP 和 MySQL 中首先显示以最高价格订购的记录

jquery - 如果函数返回 jQuery AJAX 输出作为返回

html - CSS - 响应图像大小

html - em 的上下文是什么?

php - 使用 Yii 模型创建或更新多个 mysql 行

php - PDO 选择查询错误

javascript - jsTree:progressive_render 与数组中的 ajax/render 节点

javascript - 如何退出 jQuery 的递归轮询?

javascript - 是否可以将 js 变量发送到 google 表格? (不是表单数据)

php - 使用 MySQL 和 PHP 返回单个值