简体   繁体   English

从iOS中的“共享”按钮启动应用-Objective C和React Native

[英]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.

相关问题 React Native 和 iOS 分享按钮 - React Native and iOS share button 从iOS共享AsyncStorage与Apple Watch响应本机应用 - Share AsyncStorage from iOS react native app with Apple Watch iOS:使用目标C的App Share URL - iOS: App Share URL using objective C 通过本机iOS Objective-C应用程序与Python或Java通信吗? - Communicate with Python or Java from native iOS Objective-C app? 当我尝试从React Native iOS应用程序共享我的应用程序URL时,应用程序变得无响应 - App becomes unresponsive when I tried to share my app url from react native iOS app 如何从我的IOS(Objective c)应用程序在微信应用程序上共享文本? - How to share the text on WeChat app from my IOS(Objective c) app? iOS / Objective-C:从Storyboard应用程序的子类中的代码启动UIAlertController - IOS/Objective-C: Launch UIAlertController from code in subclassed Class in Storyboard app 在启动iOS IOS Objective C时添加新的ViewController - Add new viewcontroller at launch of app IOS Objective C Objective-C / iOS共享文档以上传到我的应用中 - Objective-C / iOS share documents to upload in my app 如何在 iOS (Objective-C) 中分享 Facebook Messenger 应用程序的链接? - How to share link to Facebook Messenger app in iOS (Objective-C)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM