Skip to content

Latest commit

 

History

History
143 lines (101 loc) · 3.54 KB

setup.android.md

File metadata and controls

143 lines (101 loc) · 3.54 KB

Android Setup

Some Kontakt.io beacons prerequisites have to be met.

Auto-linking (React Native v0.60+)

  1. Add package

    $ yarn add react-native-kontaktio
  2. In android/app/src/main/AndroidManifest.xml do two things:

    • Inside the <manifest /> tag add the android.permission.ACCESS_FINE_LOCATION permission
    • Inside the <application /> tag register the Proximity <service />:

    You should add the following two lines:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example2022">
    
    	<uses-permission android:name="android.permission.INTERNET" />
    +	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
    	<application
    	android:name=".MainApplication"
    	...
    	android:theme="@style/AppTheme">
    	<activity
    		android:name=".MainActivity"
    		...
    		</intent-filter>
    	</activity>
    +	<service android:name="com.kontakt.sdk.android.ble.service.ProximityService" android:exported="false"/>
    	</application>
    </manifest>

    (... denote omitted lines)

  3. Android Marshmallow (6.0) or higher: Don't forget to ask the user to grant the android.permission.ACCESS_FINE_LOCATION permission in your application code - see the minimal example in the README).

Setup for old versions of React Native

Mostly automatic setup (React Native older than v0.60)

When installing both, Android and iOS, steps 1 and 2 only have to be run once for both platforms.

  1. Install the package

    • yarn

       $ yarn add react-native-kontaktio
    • npm

       $ npm install --save react-native-kontaktio
  2. Link module (use rnpm for React Native versions before 0.27)

     react-native link react-native-kontaktio
    
  3. In android/app/src/main/AndroidManifest.xml inside <application /> register the Proximity service:

    <service android:name="com.kontakt.sdk.android.ble.service.ProximityService" android:exported="false"/>

    i.e. your AndroidManifest.xml should look similar to this (... denote omitted lines):

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      ...
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    + <service android:name="com.kontakt.sdk.android.ble.service.ProximityService" android:exported="false"/>
    </application>

Manual setup (React Native older than v0.60)

  1. npm install

    $ npm install --save react-native-kontaktio
  2. In android/app/src/main/java/.../MainApplication.java import KontaktPackage and add it to the List:

    import com.artirigo.kontaktio.KontaktPackage;
    ...
    return Arrays.<ReactPackage>asList(
    	new MainReactPackage(),
    	...
    	new KontaktPackage()
       );
  3. In android/settings.gradle add:

    include ':react-native-kontaktio'
    project(':react-native-kontaktio').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-kontaktio/android')
    
  4. In android/app/build.gradle

    • Add dependency
    dependencies {
    	compile project(':react-native-kontaktio')
    	...
    }
    • Add exclusion inside android, i.e.
    android {
    	...
    	packagingOptions {
    		exclude 'main/AndroidManifest.xml'
    	}
    }
  5. In android/app/src/main/AndroidManifest.xml inside <application /> add

    <service android:name="com.kontakt.sdk.android.ble.service.ProximityService" android:exported="false"/>