开发者

How to use [[UIApplication sharedApplication] openURL:] open other app?

I followed http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html instruction to open app1(GlassButton) within app2(FontTest).

The open method of FontTest as following:

-(void)open {

  BOOL res = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"glassbutton://"]];

  if (res) {

    [[U开发者_Python百科IApplication sharedApplication] openURL:[NSURL URLWithString:@"glassbutton://"]];

  }

}

The value of "res" is "YES", but nothing happen after openURL method be called. The info-list of "FontTest"as following:

URL Schemes: glassbutton

URL identifier: com.yourcompany.glassbutton

I tried to open twitter and facebook apps by "twitter://" and "fb://" successfully. But I do not know why I cannot open this small app. I'm not sure whether any thing/step wrong or missing? Need I handle - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url for FontTest, if yes, how to handle it? Could you please kindly help me? Thanks in advance!


To request the launch of your app use something like this:

NSString *urlString= @"glassbutton://com.yourcompany.glassbutton";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

Then, in the glassbutton app, you'll need to handle any special behavior within the app delegate method:

 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

    //your app specific code here for handling the launch

    return YES;
 }

Note that within the app you are opening the above delegate method will only get called AFTER the following method is called:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Handle accordingly, good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜