Trigger Integration

This is the integration document for the GroundTruth Android Location Triggers.

The location triggers are used to notify mobile apps, in real-time, whenever their users visit a place or a location. This will help mobile apps to add location-based implementation.

Prerequisites

Integration Steps

You have to register for the trigger and subscribe to the event to receive trigger metadata.

Step 1: Register Triggers
In order to activate trigger callbacks, paste the below line to register for the callbacks.

RxBus.get().register(this)
RxBus.get().register(this);

Step 2: Receive Triggers
You will receive trigger callbacks in onTriggerReceived function.

@Subscribe(tags = [Tag(TRIGGER_RECEIVE_TAG)])
fun onTriggerReceived(data: HashMap<String?, Any?>) {
     // Get configured key value of triggers from data
  
     // Example: if event's key value stored as { "proximity":"US" }
     // You can fetch the event value like this
     Log.i("Trigger", "Received " + data?.get("proximity"))
       
     // Do the custom implementation here
 }
@Subscribe(tags = {@Tag(TRIGGER_RECEIVE_TAG)})
void onTriggerReceived(HashMap<String, Object> data) {
       // Get configured key value of triggers from data
  
       // Example: if event's key value stored as { "proximity":"US" }
       // You can fetch the event value like this
       Log.i("Trigger", "Received " + data.get("proximity"));
  
       // Do the custom implementation here     
 }

Step 3: Unregister Triggers
In order to de-activate trigger callbacks, paste the below line to unregister the callbacks.

RxBus.get().unregister(this)
RxBus.get().unregister(this);

Full example of Trigger Implementation

//Imports
import com.hwangjr.rxbus.RxBus
import com.hwangjr.rxbus.annotation.Subscribe
import com.hwangjr.rxbus.annotation.Tag
import static com.xad.sdk.locationsdk.GlobalConfig.Manuals.TRIGGER_RECEIVE_TAG
 
// Register
override fun onResume() {
     super.onResume()
     RxBus.get().register(this)
}

// Receive Triggers
@Subscribe(tags = [Tag(TRIGGER_RECEIVE_TAG)])
fun onTriggerReceived(data: HashMap<String?, Any?>?) {
     // Get configured key value of triggers from data
     // Do the custom implementation here
}

// Unregister
override fun onPause() {
     super.onPause()
     RxBus.get().unregister(this)
}
//Imports
import com.hwangjr.rxbus.RxBus;
import com.hwangjr.rxbus.annotation.Subscribe;
import com.hwangjr.rxbus.annotation.Tag;
import static com.xad.sdk.locationsdk.GlobalConfig.Manuals.TRIGGER_RECEIVE_TAG;

// Register
@Override
    protected void onResume() {
        super.onResume();
        RxBus.get().register(this);
    }

// Receive Triggers
@Subscribe(tags = {@Tag(TRIGGER_RECEIVE_TAG)})
void onTriggerReceived(HashMap<String, Object> data) {
       // Get configured key value of triggers from data
       // Do the custom implementation here     
 }

// Unregister
@Override
protected void onPause() {
     super.onPause();
     RxBus.get().unregister(this);
}