`
zani
  • 浏览: 356665 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

open other app from my app

 
阅读更多

1. 在需要被启动的app中的plist文件, 右击Information Property List, 选择Add Row


 

2. 选择"URL types"作为键值


3. 展开的"Item1",为URL identifier提供一个值,这个值可以是任意的, 但是惯例是使用"反向域名(reverse domain name)"(例如:com.mycompany.myapp).


 

4. 右击"Item1", 选择"Add row"

 


 

5. 选择"URL Schemes"作为键值

 


 

6. 为这个"URL Schemes"输入对应的值(例如: "myapp://"那么就输入"myapp"). 这里可以输入多个不同的值.


7. 这是在另一个程序, 启动代码:

	NSURL *url = [NSURL URLWithString:@"myapp:"];  
	[[UIApplication sharedApplication] openURL:url];

 

 

-----------------------

Optionally Handle the URL

Now that the URL has been registered. Anyone can start the application by opening a URL using your scheme.

Here are a few examples …

myapp://
 
myapp://some/path/here
 
myapp://?foo=1&bar=2
 
myapp://some/path/here?foo=1&bar=2

The iPhone SDK, when launching the application in response to any of the URLs above, will send a message to the UIApplicationDelegate.

If you want to provide a custom handler, simply provide an implementation for the message in your delegate. For example:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
  // Do something with the url here
}

A common technique is to parse the URL passed in and pull from it the parameters that will be used by various views in the application and store them in the User Preference. Below is an example where we store the URL as a value parameter “url” in just such a manner …

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if (!url) {  return NO; }
 
    NSString *URLString = [url absoluteString];
    [[NSUserDefaults standardUserDefaults] setObject:URLString forKey:@"url"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    return YES;
}

Now you have everything you need to enable others to wake-up your application and even pass it information! Enjoy!

  • 大小: 91.9 KB
  • 大小: 203.1 KB
  • 大小: 195.4 KB
  • 大小: 217.8 KB
  • 大小: 206.4 KB
  • 大小: 203.3 KB
分享到:
评论

相关推荐

    Android 使用Font和style定义App全局字体样式

    在Android中,`Font`通常指的是字体文件,通常以`.ttf`(TrueType Font)或`.otf`(OpenType Font)格式存在。这些文件包含了一系列不同的字符和字形,用于显示各种文字。要将自定义字体应用于应用程序,你需要将...

    Learning Web App Development

    Grasp the fundamentals of web application development by building a simple database-backed app from scratch, using HTML, JavaScript, and other open source tools. Through hands-on tutorials, this ...

    Android代码-在线网校Open EdX安卓版客户端

    This is the source code for the edX mobile Android app. It is changing rapidly and its structure should not be relied upon. See http://code.edx.org for other parts of the edX code base. It requires ...

    Android代码-Hews官方客户端 v1.9.0

    Hews A hacker news reader focuses on readng experience with ...Open hacker news links from other app Open post/other links in external browser Check User's HN profile (long press) Share comment l

    Unity3D如何导出为APP安装包(安卓apk和苹果版ipa)教程.zip

    - 在“Other Settings”部分,确保“Scripting Backend”是IL2CPP,且“Architecture”为ARM64,因为苹果已经不再支持32位应用。 - 在“Plist Settings”下,添加必要的元数据,如应用名称、公司标识符等。 - 在...

    Android代码-果酱音乐播放器

    Jams Music Player Jams is a free, powerful and elegant music player for Android....Rather than letting Jams completely die off, I've open sourced the app and hosted it here to encourage other develop

    OpenCore-Multiboot:OpenCore的多重启动指南-WIP

    看起来您正在尝试在系统上安装macOS和$(OtherOS) ,但是您也不想在此过程中弄乱$(OtherOS)或macOS。 在这里,将指导您通过多个步骤来实现这一目标,同时尽可能不影响操作系统设置。固件类型多重引导受您正在运行的...

    Android代码-mogujie开源IMApp

    mogujie Open Source IM App mogujie Open Source IM is aiming to provide another IM solution in your company for colleagues to communicate with each other. we've released Win/Mac/Android/iOS client ...

    Android代码-DualSim Reminder

    Dual SIM Reminder This app is intended for ...a widget lets you open Dual SIM settings directly from the home screen Currently supported phones: Huawei P9 (and probably all other Huawei phones) Samsung

    Android代码-openScale

    Monitor and track your weight, BMI, body fat, body water, muscle and other body metrics in an open source app that: has an easy to use user interface with graphs, doesn't require you to create an ...

    校园助手iOS端HutHelper-Open.zip

     │ ├── Other:其他  └── Pods:项目使用了[CocoaPods](http://code4app.com/article/cocoapods-install-usage)这个类库管理工具  └── json:请求的示例数据请注意,因为使用了Pods,所以请下载完...

    The.Busy.Coders.Guide.to.Android.Development.Version.8.3.epub

    Android, the next-generation open mobile platform from Google and the Open Handset Alliance, is poised to become a significant player in the mobile device market. The Android platform gives developers...

    Learn Swift by Building Applications Explore Swift programming

    Develop a wide range of apps, from a simple weather app to an Instagram-like social app Get ahead in the industry by learning how to use third-party libraries efficiently in your apps Who This Book Is...

    Learn Swift by Building Applications Explore Swift programming_Code.zip

    Develop a wide range of apps, from a simple weather app to an Instagram-like social app Get ahead in the industry by learning how to use third-party libraries efficiently in your apps Who This Book Is...

    BobBuilder_app

    Data pages are separate from the main tree structure, so can be freed from memory if needed, and loaded on demand. Automatic index file recovery on non-clean shutdowns. String Keys are UTF8 encoded ...

    Android代码-LnkShortener

    You can download LnkShortener from one of the following App Stores or obtain the latest binaries from the Releases page. App Stores Use LnkShortener is working out of the box. Simply share a ...

    Android代码-SoundWaves

    SoundWaves is a free, libre and open source app for fetching and listening to podcasts. Help out If you feel like helping out we are more than happy to accept any kind of help. There are a lot of ...

    Android代码-LTE Cleaner (FOSS)

    longer allows apps to clean other app's caches, thus the claim of cleaners clearing them is completely false. The only thing they can clean: log files, temporary files, and empty folders. All thre

    Learning Swift 3 Building Apps for macOS, iOS, and Beyond

    including open-source frameworks that your apps can use, how to use app extensions make your app play nice with other apps, and how to take Swift beyond Apple’s domain with open-source Swift tools.

    Ionic.2.Cookbook.2nd.Edition.epub

    By frequently speaking at local meetups as well as cloud computing/big data industry events and conferences, he learns from other experts. He holds an MBA degree from the University of Washington's ...

Global site tag (gtag.js) - Google Analytics