[英]Launch app from share button in iOS - Objective C and React Native
I'm trying to launch MyApp when user selects any image in Photos and taps in Share -> MyApp. 当用户在“照片”中选择任何图像并在“共享”->“ MyApp”中点击时,我试图启动MyApp。 Now the (UIView*) shareView
is launched successfully but I need enter to the normal flow in MyApp, I mean, launch all the app with the react native views instead the shareView
. 现在(UIView*) shareView
已成功启动,但是我需要进入MyApp中的常规流程,我的意思是,使用react native视图而不是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;
}
(The react native component is not working if is called from here, never is called or rendered) (如果从此处调用,则从不调用或呈现react本机组件,将无法正常工作)
All the permissions are working and the share button is appearing in the activity action sheet. 所有权限都在起作用,并且共享按钮显示在活动操作表中。
I would like to know if this is a impossible task (according the guidelines of apple, the share in activity sheet should be a simple task to send data, maybe using NSUserDefaults
) but I don't know if programmatically or in life cycle of iOS app this is prohibited. 我想知道这是否是一个不可能的任务(根据苹果的指导方针,活动表中的共享应该是发送数据的简单任务,也许使用NSUserDefaults
),但是我不知道是否是通过编程方式或在iOS的生命周期中进行应用程序,这是禁止的。
I try to call the app with NSURL
and adding the scheme identifier but this is not working. 我尝试使用NSURL
调用应用程序并添加方案标识符,但这不起作用。
Thanks for your help. 谢谢你的帮助。
I think you may talk about the App Sharing Extension. 我想您可能会谈论App Sharing Extension。 One thing you should know, the extension cannot access the container App's resource and data directly. 您应该知道的一件事是,扩展无法直接访问容器App的资源和数据。 If you want share the resource, you must make a App group configuration with both your extension and your container App. 如果要共享资源,则必须同时使用扩展程序和容器App进行App组配置。 Then use the sharing resource space. 然后使用共享资源空间。 NSUserDefault and NSFileManager both have the method to access the sharing space. NSUserDefault和NSFileManager都有访问共享空间的方法。 Your code directly accesses the container App's resource space, not via the sharing space. 您的代码直接访问容器App的资源空间,而不是通过共享空间。 That's why you get failed, I think. 我想,这就是为什么你失败了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.