简体   繁体   English

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

[英]How to get bundleId of the source app when using share extension in IOS8

I wanna know which app calls the share extension to share image to my app(its bundleId or appName). 我想知道哪个应用程序调用共享扩展名以将图像共享到我的应用程序(其bundleId或appName)。 But I found no way to do it. 但是我找不到办法。 There is none information about the source app in NSExtensionContext. NSExtensionContext中没有有关源应用程序的信息。 I would greatly appreciate any help. 我将不胜感激任何帮助。

To achieve what you're asking: 要实现您的要求:

#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

You don't get to find out what app is hosting your extension. 您无法找出托管您的扩展程序的应用程序。 That's not part of the extension system. 那不是扩展系统的一部分。 You get to find out what kind of data the app is passing you and, with action extensions, you get to return some data. 您可以找出应用程序正在传递给您的数据类型,并通过操作扩展来返回一些数据。 But you don't get to find out who you're dealing with, only what data is going back and forth. 但是,您无法找出要与谁打交道,而只能知道来回交换的数据是什么。

Your bundle ID is usually com.yourcompany/yourname.yourappname 您的捆绑包ID通常是com.yourcompany / yourname.yourappname

If you don't know what Xcode has for your company name, create a new project and the screen that prompts you for your app name will have your company name. 如果您不知道Xcode代表公司名称,请创建一个新项目,然后提示您输入应用程序名称的屏幕将显示您的公司名称。

Also you can do this, 你也可以做到

In Xcode, select your project, then your target (you should have only one) and then the 'Info' tab. 在Xcode中,选择您的项目,然后选择目标(应该只有一个),然后选择“信息”标签。 You should be able to see the bundle identifier there. 您应该能够在其中看到包标识符。

The answer to this question can be found here: 这个问题的答案可以在这里找到:

How to get bundle ID? 如何获取捆绑包ID?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM