Last active
May 10, 2017 21:21
-
-
Save jngnyc/d9194a4c4ecfdb64d2e0f72d43cfb941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chartiq.sampleapp.instabot_with_thirdparty_push_provider; | |
import android.content.Context; | |
import android.support.annotation.NonNull; | |
import android.util.Log; | |
import com.rokolabs.sdk.analytics.Event; | |
import com.rokolabs.sdk.analytics.RokoLogger; | |
import com.urbanairship.AirshipReceiver; | |
import com.urbanairship.push.PushMessage; | |
public class SampleAirshipReceiver extends AirshipReceiver { | |
private static final String TAG = "SampleAirshipReceiver"; | |
@Override | |
protected void onPushReceived(@NonNull Context context, @NonNull PushMessage message, boolean notificationPosted) { | |
Log.i(TAG, "Received push message. Alert: " + message.getAlert() + ". posted notification: " + notificationPosted); | |
// log this event to ROKO Mobi | |
RokoLogger.addEvents(new Event("received Urban Airship push")); | |
// parse out the value for the key 'mobi_instabot_trigger' that was configured in Urban Airship push message | |
String instabot_trigger_key = "mobi_instabot_trigger"; | |
String instabot_trigger_value = message.getPushBundle().getString(instabot_trigger_key); | |
// send a specific Mobi event based on the key/value pair attached in the Urban Airship push message | |
// each of these Mobi events will be available in the Mobi portal as an option for you to trigger a Mobi InstaBot | |
String mobiEventName; | |
switch (Integer.parseInt(instabot_trigger_value)) { | |
case 1: | |
mobiEventName = "InstaBot trigger 1"; | |
break; | |
case 2: | |
mobiEventName = "InstaBot trigger 2"; | |
break; | |
case 3: | |
mobiEventName = "InstaBot trigger 3"; | |
break; | |
default: | |
mobiEventName = "InstaBot trigger - UNDEFINED"; | |
break; | |
} | |
RokoLogger.addEvents(new Event(mobiEventName)); | |
Log.i(TAG, "Sending a Mobi event with the name: " + mobiEventName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment