我正在尝试在用户选择照片中的任何图像并点击共享 -> MyApp 时启动 MyApp。
现在 (UIView*) shareView
已成功启动,但我需要进入 MyApp 中的正常流程,我的意思是,使用 react native View 而不是 shareView
启动所有应用程序.
- (UIView*) shareView {
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"src/components/share/share" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Share"
initialProperties:nil
launchOptions:nil];
UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 200, 40)];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setText:@"THIS IS A LABEL FOR TEST"];
[rootView addSubview:myLabel];
rootView.backgroundColor = UIColor.whiteColor;
return rootView;
}
(如果从这里调用,则 React Native 组件不工作,永远不会被调用或呈现)
所有权限均有效,共享按钮出现在事件操作表中。
我想知道这是否是一个不可能的任务(根据苹果的指导方针,事件表中的共享应该是一个发送数据的简单任务,也许使用NSUserDefaults
),但我不知道不知道这是否以编程方式或在 iOS 应用程序的生命周期中被禁止。
我尝试使用 NSURL
调用应用程序并添加方案标识符,但这不起作用。
感谢您的帮助。
最佳答案
我想您可能会谈谈 App Sharing Extension。你应该知道的一件事,扩展不能直接访问容器应用程序的资源和数据。如果你想共享资源,你必须为你的扩展和你的容器应用程序做一个应用程序组配置。然后使用共享资源空间。 NSUserDefault 和 NSFileManager 都有访问共享空间的方法。您的代码直接访问容器 App 的资源空间,而不是通过共享空间。我认为这就是你失败的原因。
关于ios - 从 iOS 中的共享按钮启动应用程序 - Objective C 和 React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48470663/