创建自定义URL方案操作

ato*_*nda 2 iphone url objective-c url-scheme ios

我知道如何创建自定义,URL schemes但如何向其添加操作?我如何将信息传递到我的应用程序中.

任何建议都会很棒!

run*_*mad 6

你必须弄清楚行动..但这是一个例子:

yourAppURL://doSomething
Run Code Online (Sandbox Code Playgroud)

要么

yourAppURL://doAnotherThing
Run Code Online (Sandbox Code Playgroud)

然后在你的 AppDelegate

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    NSString *text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    if ([text isEqualToString:@"doSomething"]) {
        // then do something
    }
    if ([text isEqualToString:@"doAnotherThing"]) {
        // do another thing
    }
}
Run Code Online (Sandbox Code Playgroud)

你可以通过在URL中发送各种文本来做各种事情.例如,Facebook使用它打开应用程序直接转到配置文件facebook://profile=username