Source: https://developers.woosmap.com/products/geofencing-sdk/integration/airship/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Airship integration



Woosmap Geofencing SDK can send events to [Airship](https://www.airship.com/) from different context types:
Geofences, POI, Visits and ZOI.

Whenever location events trigger, you can send custom events with associated properties to your App via a listener
method. Your App can then pass them to the Airship SDK and use the *Custom Event* trigger in the Automation and Journey composers.

## Airship Integration

### Requirements

- **SDK version 6.0 or later**: Download the latest stable SDK from
   [appropriate platform page](https://docs.airship.com/developer/).
- **Account Entitlements**: Account-level permissions apply, based on your pricing package. Contact Airship Sales with
   any questions related to pricing and entitlements for location and automation services.

### Configuration

To configure your app with the Airship SDK follow the instructions on the dedicated *Getting Started* guide on <https://docs.airship.com/guides/>.

### Send Airship Custom events from native code
Custom events let you track user activities and key conversions in your mobile app, and tie them back to corresponding push messaging campaigns. 
For a more detailed explanation on custom events and possible use cases, see the [Airship Custom Events topic guide](https://docs.airship.com/guides/messaging/user-guide/data/custom-events/).

**iOS - Swift example**

```swift
public class AirshipEvents: AirshipEventsDelegate {
    
    public init() {}
    
    public func regionEnterEvent(regionEvent: Dictionary<String, Any>, eventName: String) {
        #if canImport(AirshipCore)
            var event = UACustomEvent(name: eventName, value: 1)
            try? event.setProperties(regionEvent)
            event.track()
        #endif
    }
```

**Android - Java example**

```java
public class WoosRegionLogReadyListener implements Woosmap.RegionLogReadyListener {
    public void RegionLogReadyCallback(RegionLog regionLog) {
        onRegionLogCallback(regionLog);
    }
}

private void onRegionLogCallback(RegionLog regionLog) {
    if(AIRSHIP) {
        // Create and name an event
        CustomEvent.Builder eventBuilder = new CustomEvent.Builder(regionLog.didEnter ? "geofence_entered_event" : "geofence_exited_event");

        // Set custom event properties on the builder
        eventBuilder.addProperty("id",regionLog.id);
        eventBuilder.addProperty("radius", regionLog.radius);
        eventBuilder.addProperty("latitude", regionLog.lat);
        eventBuilder.addProperty("longitude", regionLog.lng);

        // Then record it
        CustomEvent event = eventBuilder.build();
        event.track();
    }
}
```

### Send Airship Custom events from `react-native-plugin-geofencing`

To enhance the functionality of your app, you integrate Airship and configure it with your Airship account. For expert guidance on the setup and configuration process, kindly refer to the following links: https://docs.airship.com/platform/mobile/setup/sdk/react-native/.
You can easily activate Airship event tracking in the geofence SDK once it has been integrated.

**Enable the `enableAirshipConnector` parameter:**

```js
import WoosmapGeofencing from '@woosmap/react-native-plugin-geofencing';
...
...
WoosmapGeofencing.initialize({
  privateKeyWoosmapAPI: '<<your key>>',
  enableAirshipConnector: true,
}).catch(error => {
  console.error(error);
});
```

Then some additional steps are required for Android and iOS:

**For iOS**
Update your Podfile with this line and run `pod install --repo-update`
```
pod 'react-native-plugin-geofencing/Airship', :path => '../node_modules/@woosmap/react-native-plugin-geofencing'
```
**For Android**
1. Compile and Target SDK Versions:

Please update the build.gradle file:

```
android {
   compileSdkVersion 31

   defaultConfig {
         minSdkVersion 21
         targetSdkVersion 31

         // ...
   }
}
```

2. If you are obfuscating your APK then please add following rules in your `proguard.rules` file.

```
-keep class org.json.** { *; }
-keepnames class org.json.** { *; }
-keep class com.urbanairship.** { *; }
-keepnames class com.urbanairship.** { *; }
```

Once Airship SDK initialized, `enableAirshipConnector` parameter enabled and additional steps for Android and iOS done, `woos_geofence_entered_event` and `woos_geofence_exited_event` events will be automatically pushed to the Airship platform.

### Send Airship Custom events from `geofencing_flutter_plugin`

To enhance the functionality of your app, you integrate Airship and configure it with your Airship account. For expert guidance on the setup and configuration process, kindly refer to the following links: https://docs.airship.com/platform/mobile/setup/sdk/flutter/.
You can easily activate Airship event tracking in the geofence SDK once it has been integrated.

**Enable the `enableAirshipConnector` parameter:**

```dart
import 'package:geofencing_flutter_plugin/geofencing_flutter_plugin.dart';

final geofencingFlutterPlugin = GeofencingFlutterPlugin();
...
...
geofencingFlutterPlugin.initialize({
  privateKeyWoosmapAPI: '<<your key>>',
  enableAirshipConnector: true,
}).catch(error => {
  console.error(error);
});
```

Then some additional steps are required for Android and iOS:

**For iOS**
Update your Podfile with this line and run `pod install --repo-update`

``` swift
pod 'geofencing_flutter_plugin/Airship', :path => '.symlinks/plugins/geofencing_flutter_plugin/ios'
```

**For Android**

1. Compile and Target SDK Versions:

Please update the build.gradle file:

``` ruby
android {
   compileSdkVersion 31

   defaultConfig {
         minSdkVersion 21
         targetSdkVersion 31

         // ...
   }
}
```

2. If you are obfuscating your APK then please add following rules in your `proguard.rules` file.

``` ruby
-keep class org.json.** { *; }
-keepnames class org.json.** { *; }
-keep class com.urbanairship.** { *; }
-keepnames class com.urbanairship.** { *; }
```

Once Airship SDK initialized, `enableAirshipConnector` parameter enabled and additional steps for Android and iOS done, `woos_geofence_entered_event` and `woos_geofence_exited_event` events will be automatically pushed to the Airship platform.

## Events definition

### Geofences Events

- Enter eventName: `woos_geofence_entered_event`
- Exit eventName: `woos_geofence_exited_event`

**Event data specification**

| Field name                       | Type   | Only if the region is a POI |
| -------------------------------- | ------ | --------------------------- |
| `date`                             | Datetime  |                             |
| `id`                               | String |                             |
| `latitude`                         | Double |                             |
| `longitude`                        | Double |                             |
| `radius`                           | Double |                             |
| `name`                             | String | X                           |
| `idStore`                          | String | X                           |
| `city`                             | String | X                           |
| `zipCode`                          | String | X                           |
| `country_code`                    | String | X                           |
| `address`                          | String | X                           |
| `tags`                             | String | X                           |
| `types`                            | String | X                           |
| `user_properties.[field_name]` | String | X                           |

### POI Events

- eventName: `woos_POI_event`

**Event data specification**

| Field name                       | Type   |
| -------------------------------- | ------ |
| `date`                             | Datetime   |
| `name`                             | String |
| `idStore`                          | String |
| `city`                             | String |
| `zipCode`                          | String |
| `distance`                         | String |
| `country_code`                    | String |
| `address`                          | String |
| `tags`                             | String |
| `types`                            | String |
| `user_properties.[field_name]` | String |
