![]() We will create a File called RNShare.swift on ios folder from our React Native app. The first step, is create the function that you need on native part like an implementation on native apps. In this article, we will see how to use Swift to integrate our app with Share with social medias native popover. But how we can see on documentation we also can bridge our application with Swift to use these functionalities. Mostly React Native code is written with Objective-C because React Native core uses Yoga lib for layout that works better bridging with Objective-C because is written in C++. For iOS, you can choose between Swift and Objective-C to implement these features on your app. Some features available to use on user phones only can be accessed with native code like Camera, Geolocation, Bluetooth, and more. To follow this tutorial, you will need to have a React Native app, and if you don't have yet, you can start a new one using npx react-native init.Ĭurrently, is not possible to integrate native code with Expo Managed Workflow, but you can use Expo CLI with Bare Worflow if you prefer. We still need to use some Objective-C to be able to use Swift, but this thing maybe can change soon. With the grew of Swift language, have been popular create Native Modules with Swift for React Native apps on iOS. ![]() If you are not familiar with Native Modules on React Native - and it's ok because this tutorial is for you too! - know that it's most common to integrate a React Native with Objective-C (iOS) and Java (Android), but recently this have changed. Same as with WhatsApp or Instagram Stories, the urlScheme is needed for Facebook sharing.Īnd that's pretty much all you need to know about sharing images on Facebook, WhatsApp and Instagram using iOS Swift.In this post, we will integrate a React Native app with share on social media feature on iOS using Swift. Unless you add it, sharing won’t be working properly. The appID should be added to the ist file. The Facebook developer documentation says that appID is required as your Facebook app ID. (urlScheme, options:, completionHandler: nil)Īs you can see, besides ImageData, there is also appID. It can be a simple UIView, UIStackView, UITableView, etc.įunc shareToFacebook(image: UIImage, urlScheme: URL, appId: String) In that case, we should embed our views inside one view. It can be UIController’s view, but if we don’t want to get navigation elements, we should use another approach. Let’s start with embedding the prepared views into one UIView. To do this, we need to prepare UIImage from UIView, then change it to Data and pass it to other social media apps. We want to pass it to Facebook or WhatsApp. Let’s say, we have a controller that shows images, labels, buttons, etc. Be it from API, hardcoded in your iOS application, or somewhere else.īut in other cases, you’ll need to prepare an image from the view displayed in the application. In many cases, you’ll have a ready image. ![]() The first thing is to prepare UIImage for sharing. So, without further ado, let the fun begin! Table of content Preparing images is quite easy, although, in the case of Facebook, you’ll need a special client ID.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |