Skip to content

Instantly share code, notes, and snippets.

@hiyali
Created March 23, 2018 11:27
Show Gist options
  • Save hiyali/77e5774d3f6e0cf81936c9c9d1b49d91 to your computer and use it in GitHub Desktop.
Save hiyali/77e5774d3f6e0cf81936c9c9d1b49d91 to your computer and use it in GitHub Desktop.
cordova-wechat-share-app-delegate.md

修改文件AppDelegate+IonicDeeplink.m的openURL方法,内容改成下面的:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    BOOL handled = NO;

    if ([[url absoluteString] rangeOfString:@"liepiao"].location == 0) {
        IonicDeeplinkPlugin *plugin = [self.viewController getCommandInstance:PLUGIN_NAME];
        if(plugin == nil) {
            NSLog(@"Unable to get instance of command plugin");
        }
        handled = [plugin handleLink:url];
    }

    if(!handled) {
      // Pass event through to Cordova
      [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];

      // Send notice to the rest of our plugin that we didn't handle this URL
      [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"IonicLinksUnhandledURL" object:[url absoluteString]]];
    }

    return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment