React Native - iOS Specifics
On this page, you will find how to configure all the specific codes for your iOS App
This section requires that you have successfully initialized the Group Link SDK from the Quickstart React Native.
Step 1 - Requesting Permissions
First of all, you need to insert inside your info.plist file (you can find this file inside the ios folder) the necessary permissions and strings, you can follow the iOS Required Permissions manual to learn more.
Step 2 - Installing the Group Link SDK Pod
After the initialization, you have to change the terminal directory to the ios folder of your project and run the pod install command to install the Group Link framework inside the Xcode project of your React Native App.
Step 3 - Starting BLE on iOS
In the code snippet below, you can see how to call the BLE function from our React Native library. In this example, we call it inside the App function at the start of the application.
import * as GroupLinkSDK from "@grouplinknetwork/rn-grouplink-sdk";
export default function App() {
GroupLinkSDK.startBluetoothIOS();
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
Remember to always check if the user has granted Bluetooth permission when initializing your application, with the checkBluetooth() SDK function.
import * as GroupLinkSDK from '@grouplinknetwork/rn-grouplink-sdk';
export default function App() {
// You need to run this function to check if the user has granted bluetooth permission,
// this function will not ask anything, you have to call startBluetooth() function to ask for permission.
GroupLinkSDK.checkBluetooth();
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
Step 4 - Starting the Location Service on iOS
In the snippet below, you can find how to call the location function from our React Native library, in this example, we call inside the App function that is in the application start. This function is only required if you don't use location services in your app, if you already use them, you can skip this part.
import * as GroupLinkSDK from "@grouplinknetwork/rn-grouplink-sdk";
export default function App() {
GroupLinkSDK.startLocationIOS();
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
Step 5 - iOS Remote Notification Token
Now you have to pass the device remote notification token, and the function receives a String (device token), in React Native you have many ways to get this token, below we provide a snippet to get the token from the Firebase framework for React Native.
import * as GroupLinkSDK from "@grouplinknetwork/rn-grouplink-sdk";
import messaging from "@react-native-firebase/messaging";
export default function App() {
useEffect(() => {
messaging()
.getToken()
.then((token) => {
GroupLinkSDK.setDevicePushTokenIOS(token);
});
// listen for device token changes
return messaging().onTokenRefresh((token) => {
GroupLinkSDK.setDevicePushTokenIOS(token);
});
}, []);
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
To finish the iOS setup, follow the Push Notification tutorial on your React Native App.