Some Kontakt.io beacons prerequisites have to be met.
-
Add package
$ yarn add react-native-kontaktio
-
Install the pod
$ cd ios $ pod install
-
Add permissions as described in the 'Add permissions' section.
Open XCode (e.g. via xed -b ios
) and go to the Info tab.
In the top section Custom iOS Target Properties
add the following permissions:
-
Bluetooth
Key Value Description NSBluetoothAlwaysUsageDescription Your text of the permission for the user A message that tells the user why the app needs access to Bluetooth. See documentation for more information Just copy-paste the key from here and the text will automatically change to the more elaborate version when you press enter (for example):
-
Location
Choose either the first or the second permission and if you target iOS versions earlier than iOS 11, add the third permission.
Key Value Description NSLocationWhenInUseUsageDescription iOS 11.0+ Grant permission to access location when the app is in use A message that tells the user why the app is requesting access to the user’s location information while the app is running in the foreground. See documentation for more information NSLocationAlwaysAndWhenInUseUsageDescription iOS 11.0+ Grant permission to access location when the app is in use and when it is in the background A message that tells the user why the app is requesting access to the user’s location information at all times. See documentation for more information --- --- --- NSLocationAlwaysUsageDescription DEPRECATED in iOS versions 11.0+ - Use this key if your iOS app accesses location information in the background, and you deploy to a target earlier than iOS 11. A message that tells the user why the app is requesting access to the user’s location information at all times (i.e. even when the app is in the background). See documentation for more information
-
In case you run into the build error
Command PhaseScriptExecution failed with a nonzero exit code
check whether theRun Script
in theBuild Phases
section is the last entry. If not, drag theRun Script
down so that it is.
When installing both, Android and iOS, steps 1 and 2 only have to be run once for both platforms.
-
Install the package
$ yarn add react-native-kontaktio
-
Link module (use
rnpm
for React Native versions older than0.27
)$ react-native link react-native-kontaktio
-
Add permissions as described in the next section.
-
(Skip for RN >= 0.60) Manually link Kontakt.io SDK
-
Open the projects workspace in XCode
open ios/MyProjectName.xcodeproj
-
Select your build target in the
Project navigator
. ClickGeneral
and then in theEmbedded Binaries
section, click the+
button. -
Click
[Add Other...]
. -
Navigate to
node_modules/react-native-kontaktio/ios
. -
Add
KontaktSDK.framework
. -
Leave the selection as is (don't copy to destination)
It should now also appear both in the
Embedded Binaries
section as well as in theLinked Frameworks and Libraries
section below it. -
-
(Skip for RN >= 0.60) Add Framework Search paths so that Xcode can find the added framework
-
(Skip for RN >= 0.60) Add run script
- In the
Build Phases
tab, click the+
button at the top and selectNew Run Script Phase
. Enter the following code into the script text field:
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/KontaktSDK.framework/strip-frameworks.sh"
- In the