简体   繁体   English

在IOS中共享图像/链接到我的应用程序

[英]Sharing an image/link to my app in IOS

I'm trying to find out how I can add sharing support to my app using React Native. 我正在尝试找出如何使用React Native将共享支持添加到我的应用程序中。 I've found documentation for displaying the action sheet from within my app but nothing on how I can add support for users to share images/links to my app. 我找到了用于在我的应用程序中显示操作表的文档,但是没有关于如何添加支持用户共享图像/链接到我的应用程序的文档 I'm not even sure what Apple calls this feature so it's possible I may not be searching with the right keywords. 我什至不确定Apple称之为什么功能,因此我可能没有使用正确的关键字进行搜索。

eg 例如 屏幕截图

On #1 if you press the share button at the bottom middle of the safari app it will bring up a popup where you can choose an app eg Facebook, then if you press on Facebook it will open Facebook with a url to the page you want to share from safari where you can add a comment about the link. 在#1上,如果您按下safari应用程序底部中间的共享按钮,它将弹出一个弹出窗口,供您选择一个应用程序,例如Facebook,然后,如果您在Facebook上按下,它将打开Facebook,并提供您想要的页面网址从safari中共享,您可以在其中添加有关链接的评论。 I want to replicate this behavior but within my own app. 我想在我自己的应用程序中复制此行为。 I want my app to be available to choose when I press the share button on the safari app which I will then open a popup window that displays the link the user wants to share allowing them to add a comment before posting the link. 我希望我在浏览器上按下共享按钮时可以选择我的应用程序,然后我将打开一个弹出窗口,该窗口显示用户想要共享的链接,允许他们在发布链接之前添加评论。 Is this possible with react native? 通过本机反应可能吗? I see that I have the option share with other apps (my fidelity app, sears shop your way, etc so It seems like you can have a non system app do this. 我看到我可以与其他应用程序共享选项(我的保真度应用程序,按照您的方式进行搜索等),因此看来您可以让非系统应用程序执行此操作。

They are called Share extensions and they are part of the Extensibility features. 它们称为共享扩展,它们是可扩展性功能的一部分。 They are system-wide Share Sheets. 它们是系统范围内的共享表。 Not to be mistaken with Action Extensions. 不要误以为动作扩展。

  • Share extensions have colored icons. 共享扩展名带有彩色图标。
  • Action extensions use monochromatic icons. 动作扩展使用单色图标。

Anyway the links do not display UNTIL you have clicked the app in the share sheet. 无论如何,链接不会显示,除非您在共享表中单击了该应用程序。

  1. Editor > Add Target > iOS > Application Extension > Share Extension 编辑器>添加目标> iOS>应用程序扩展>共享扩展
  2. Configure the App Group for your app target. 为您的应用目标配置应用组。
  3. On the Capabilities tab, turn on the App Groups switch and select the group you created. 在“功能”选项卡上,打开“应用程序组”开关,然后选择您创建的组。 (if you want to enable code sharing between the extension and container app you can put the code in a framework and link to it) (如果要启用扩展程序和容器应用程序之间的代码共享,可以将代码放在框架中并链接到它)
  4. Expand the group you created and you will see a storyboard file, an entitlements file, a view controller and a plist file under the Supporting Files group. 展开您创建的组,您将在“支持文件”组下看到一个故事板文件,一个权利文件,一个视图控制器和一个plist文件。
  5. You can use the storyboard file to create a custom interface or do it programatically but Share extensions come with a default compose view that looks like the Facebook and Twitter views. 您可以使用情节提要文件来创建自定义界面,也可以通过编程方式进行操作,但是Share extensions具有默认的compose视图,类似于Facebook和Twitter视图。

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

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