custom URL scheme does not work when app is not running in background

亡梦爱人 提交于 2019-12-05 19:33:36

i was facing the same problem.

Seems that our code was running too fast.

Inserting a delay to run your custom code will resolve the issue.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(yourCustomActions) userInfo:nil repeats:NO];

    return YES;
}

Hope it helps

Got to your info.plist and perform the necessary changes

  1. Add new row --> URL types
  2. expand it
  3. in item 0 add new row ---> URL Schemes
  4. expand it
  5. In Item 0 under it, add the custom url you want to use

  6. add one row under item 0 of urlTypes --> URL identifier

  7. provide the bundle id of your app there

eg: anubhab://stackoverflow.com/

for the above custom url you would set the URL Scheme item 0 as: anubhab

see the image attached for detail

I have followed these link. Hope it helps. It works fine for me even if I kill the app from background.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!