在IOS8中使用共享扩展时如何获取源应用程序的bundleId

And*_*rew 0 xcode ios ios8 ios8-share-extension

我想知道哪个应用程序调用共享扩展以将图像共享到我的应用程序(其bundleId或appName).但我发现无法做到这一点.NSExtensionContext中没有关于源应用程序的信息.我非常感谢任何帮助.

小智 6

为了实现你所要求的:

#ifdef HIDE_POST_DIALOG
- ( void ) willMoveToParentViewController: ( UIViewController * ) parent
{
    // This is called at the point where the Post dialog is about to be shown.

    NSString * hostBundleID =  [parent valueForKey:(@"_hostBundleID")];    
    NSLog( @"****  parent bundle id is %@" ,hostBundleID);
}
#endif
Run Code Online (Sandbox Code Playgroud)

  • 使用此功能是否会导致您的应用程序被拒绝提交? (2认同)