共享链接,打开我的应用程序或应用程序商店 [英] Shared link that will open my app or the app store
问题描述
我已经开始在iPhone上的应用程序工作,我决定,我希望用户能够分享它的东西在网络上(通过电子邮件,Facebook,微博,邮件等...)。现在我想链接到应用程序(对用户的共享后),可以检查我的应用程序是否安装在设备上,并打开它通过它的URL方案,并在情况下,它不是 - 打开一个不同的链接,导致应用程序在App Store上。
我做了一些研究和了解,我应该做一个PHP在我的服务器端或东西沿着这些线路,我就怎么过找不到教程或傻瓜一个明显的例子(我什么都不知道关于PHP / JScript的/ jQuery的)......可能有人请点击这里给我个忙吗?
- (IBAction为)openOtherAppButtonAction
{
UIApplication的* ourApplication = [UIApplication的sharedApplication]
* NSString的URLEn codedText = [@APPNAMEstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
* NSString的= ourPath [@openapp://stringByAppendingString:URLEn codedText]。 // openapp是url自定义方案的名称。
NSURL * ourURL = [NSURL URLWithString:ourPath]; //,而不是我们的道路,你可以直接编写@openapp 如果([ourApplication canOpenURL:ourURL])
[ourApplication的OpenURL:ourURL];
其他
{
//显示错误
UIAlertView中* alertView = [[UIAlertView中页头] initWithTitle:@接收器未找到消息:@没有安装接收器的应用程序。代表:无cancelButtonTitle:@OKotherButtonTitles:无];
[alertView秀]
//或打开链接
[UIApplication的sharedApplication]的OpenURL:[NSURL URLWithString:@www.urlForApp.com]];
}
}
//现在对应的应用程序要打开走的info.plist
1添加一个新行名----> URL类型
2现在,在项0添加另一个名为对象------> URL方案
3现在,在项目的URL方案的0给通过它,你要打开你的应用程序用于例如名字@openapp
4你必须要打开应用程序的应用程序委托写这个
- (BOOL)应用:(*的UIApplication)的应用handleOpenURL:(NSURL *)网址{返回YES; }
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.
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"]];
}
}
// Now which app you want to open go its info.plist
1 Add a new row with name ----> URL types
2 Now in Item 0 add another object named ------> URL Schemes
3 Now at Item 0 of URL Schemes give the name through which you want to open your app for e.g @"openapp"
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屋!