将打开我的应用程序或应用程序商店的共享链接 [英] Shared link that will open my app or the app store

查看:32
本文介绍了将打开我的应用程序或应用程序商店的共享链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have started working on an iPhone app and I decided I want the user to be able to share things from it on the web (through email, Facebook, twitter, messages and so on...). Now I want the link to the app (on the user's shared post) to be able to check whether my app is installed on the device and open it through it's URL scheme and in case it's not - Open a different link that leads to the app on the App Store.

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

I have done some research and understood that I should make a php on my server side or something along these lines, how ever I couldn't find a tutorial or a clear example for dummies (i know nothing about php/jscript/jquery)... could someone please give me a hand here?

推荐答案

- (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

// Now which app you want to open go its info.plist

1 添加名称为 ----> URL types 的新行

1 Add a new row with name ----> URL types

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

2 Now in Item 0 add another object named ------> URL Schemes

3 现在在 URL Schemes 的 Item 0 给出你想通过它打开你的应用程序的名称,例如 @"openapp"

3 Now at Item 0 of URL Schemes give the name through which you want to open your app for e.g @"openapp"

4 您必须在要打开的应用程序的应用程序委托中编写此内容

4 You have to write this in app delegate of the app you want to open

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

这篇关于将打开我的应用程序或应用程序商店的共享链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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