Android SDK - Push Notification

Push Notification Activation

i. Setup Google Cloud Messaging

Prerequisites for Google Cloud Messaging Setup

This doc assumes you have already set up Google Play Services in your application project. Google Play Services is needed to use Google Cloud Messaging (GCM), the notification gateway RadiumOne Connect will use for your Android app. Also if you have not done so already, you will need to add the app you will be using to the RadiumOne Connect portal in order to add the Google API Key to it once you have generated the API Key following the steps below.

Configuring your App for GCM

Obtain an API key from Google

In order to use RadiumOne Connect with your application you will need an API key from Google. We will summarize those steps here, but for more info on this process please visit “GCM Getting Started” here.

1. Create a Google API project in Google APIs Console (take note of your project number which is the value after #project: it will be used later as your GCM sender ID)

2. Enable the GCM Service

3. Create a new Server key in the Google APIs Console page under API Access. when prompted, allow access to ip 0.0.0.0/0

4. Copy the key, it is used for GCM Connection Servers and for RadiumOne Connect setup

Setting up the API Key on R1 Connect

1. Please make sure you are signed into your account on RadiumOne Connect and go to the application you want to add this API key to.

2. Next, in the side menu go to Dev Tools > Push Services > Google Cloud Messaging.

3. Add your API Key to the API Key field and click Save.

If it saved correctly you will see a green badge with a white checkmark in it. Now your app is setup with GCM.

ii. Initialization

To make sure push notifications work correctly, please follow these steps:

Configure the r1connect.properties file in your project:

• push.sender_id – You will need to enter the project number you received when creating your Google API project.

• push.client_key=<YOUR CLIENT KEY> - Obtain your Client key from the "Settings" page in your Connect dashboard.

• push.enable – This defaults to “true” and will enable or disable push notifications after you start your application

Create a class that inherits from the class Application (or you can use an existing one in the project)

To enable an action such as opening the app when a notification is clicked, create a class that inherits from BroadcastReceiver and add the necessary logic to it. If you are okay with the default, which closes the notification upon pressing it, then no further coding is required.

public class TestPushReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        try{
            Context applicationContex = context.getApplicationContext();
            if ( intent != null && intent.getAction() != null){
                if (intent.getAction().equals(R1Push.OPENED_NOTIFICATION)){
                    Intent openIntent = new Intent(context, ShowNotificationActivity.class);
                    openIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
                        if ( intent.getExtras() != null ){
                            openIntent.putExtras(intent.getExtras());
                        }
                        applicationContex.startActivity(openIntent);
                    }
                }
            } catch (Exception ex){
        }
    }
}

Then update the application class:

public class MyApplication extends Application{
    @Override
    public void onCreate() {
        super.onCreate();
        // drawable in notification bar
        R1Emitter.getInstance().setNotificationIconResourceId(this, R.drawable.notification_icon);
        // custom BroadcastReceiver
        R1Emitter.getInstance().setIntentReceiver(this, TestPushReceiver.class);
        R1Emitter.getInstance().connect(this);
    }
}

If you don't have an application class yet, create it and don't forget to reference it inside the Manifest:

<!-- android:name of application tag must be full application name that was created in first step.-->
<application
    android:name="com.example.r1connecttestapplication.MyApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

If you want to create your own notifications you have to create a class that implements R1NotificationBuilder interface and write your notification builder like in the example below:

public class CustomNotificationBuilder implements R1NotificationBuilder {

    private int lastId;

    @Override
    public Notification createNotification(Context context, Intent intent) {
        if ( context == null || intent == null){
            return null;
        }
        String text = intent.getStringExtra(R1PushNotificationManager.NOTIFICATION_KEY);
        String title = intent.getStringExtra(R1PushNotificationManager.NOTIFICATION_TITLE);
        if ( text != null ){
            NotificationCompat.Builder nb = new NotificationCompat.Builder(context)
                .setAutoCancel(true)
                .setTicker(text)
                .setContentText(text)
                .setWhen(System.currentTimeMillis());
            if (!TextUtils.isEmpty(title)){
                nb.setContentTitle(title);
            } else {
                nb.setContentTitle("My Application Name");
            }
            nb.setDefaults(Notification.DEFAULT_ALL);
            nb.setSmallIcon(R.drawable.ic_launcher);
            Notification notification = nb.build();
            lastId++;
            return notification;
        }
        return null;
    }

    @Override
    public int getLastNotificationId() {
        return lastId;
    }
}

After that add this line just before R1Emitter.getInstance().connect(this) in your application class:

R1Emitter.getInstance().setNotificationBuilder(new CustomNotificationBuilder());

Update the manifest as shown below.

Add the following inside the application tag:

    <!-- PUSH -->
    <receiver android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <!-- name must be your applicationPackage -->
            <category android:name="###YOUR APPLICATION PACKAGE###" />
        </intent-filter>
    </receiver>
    <service
        android:name="com.radiumone.emitter.gcm.RegistrationIntentService"
        android:exported="false" />
    <service
        android:name="com.radiumone.emitter.gcm.R1ConnectGCMListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:name="com.radiumone.emitter.gcm.R1ConnectInstanceIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
    <receiver android:name="com.radiumone.emitter.push.R1PushBroadcastReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="com.radiumone.r1push.OPENED_INTERNAL"/>
        </intent-filter>
    </receiver>
    <service android:name="com.radiumone.emitter.push.R1ConnectService"/>
    <service android:name="com.radiumone.emitter.location.LocationService"/>
    //Using the class created in Step 2 (cont…):
    <receiver android:name=".testpush.TestPushReceiver"
      android:exported="false">
        <intent-filter>
            <action android:name="com.radiumone.r1push.OPENED"/>
        </intent-filter>
    </receiver>


    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <!-- END OF PUSH -->

Add the following inside the manifest tag:

<!-- PUSH -->
<!-- Permissions that are necessary for the library to work: -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to get location when using the network -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Permission to get location when using GPS --> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>

<!-- GET Accounts permission is required to make GCM working for Android devices below 4.0.4-->
<uses-permission android:name="android.permission.GET_ACCOUNTS" android:maxSdkVersion="14"/>

<uses-permission android:name="android.permission.VIBRATE"/>
<permission android:name="###YOUR APPLICATION PACKAGE###.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="###YOUR APPLICATION PACKAGE###.permission.C2D_MESSAGE"></uses-permission>
<!-- END OF PUSH -->

iii. Rich Push Initialization

Rich push notifications send a URL that opens upon user response to a system notification. In addition to the general push setup requirements, if you would like to enable rich push notifications that include HTML/CSS/JavaScript you have to add the following data in the AndroidManifest.xml:

<service android:name="com.radiumone.emitter.richpush.R1RichPushService" />
<activity
        android:name="com.radiumone.emitter.richpush.activity.R1RichPushActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/title_activity_rich_push"
        android:launchMode="singleTask"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppThemeCustomNoTitle"
        android:windowSoftInputMode="stateHidden">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity" />
</activity>

The parent activity for rich activity is the view accessed when selecting the back button. Older platforms may require the meta-data attributes above.

@style/AppThemeCustomNoTitle is the window style. If you would like to present the view without a title, use the following style:

    <style name="AppThemeCustomNoTitle" parent="AppTheme">
        <item name="android:windowNoTitle">true</item>
    </style>

Users that select rich push notifications will by default start com.radiumone.emitter.richpush.activity.R1RichPushActivity and start the HTML content.

iv. Rich Push Customization

If you want to customize Rich Push then update your custom BroadcastReceiver ( TestPushReceiver ):

Bundle extras = intent.getExtras();

if (extras != null) {
        // getting rich push ID - no rich push id means that push is simple and no rich content for it
        String richPushId = extras.getString(R1PushNotificationManager.RICH_PUSH);
        if (TextUtils.isEmpty(richPushId)) {
        openIntent = new Intent(applicationContext, ShowNotificationActivity.class);
        } else {
                openIntent = new Intent(applicationContext, R1RichPushActivity.class);
                openIntent.putExtra(R1RichPush.R1_RICH_PUSH_ID, richPushId);
        }
}

In this scenario, we check for rich push id in extras and start different activities for rich and regular push.

You can change the activity for Rich Push if you want to use fragments, toolbar, or another activity that you want to use as the Rich Push Activity. See the code below:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;

import com.radiumone.emitter.richpush.R1RichPush;
import com.radiumone.emitter.richpush.R1RichPushManager;
import com.radiumone.emitter.richpush.R1RichPushMessage;
import com.radiumone.emitter.richpush.R1RichPushWebView;

public class CustomPushActivity extends Activity implements R1RichPushManager.OnMessageReceivedListener{

    private String richPushId;
    private R1RichPushWebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle extras = getIntent().getExtras();
        if ( extras == null ){
            Log.i(CustomPushActivity.class.getSimpleName(), "Wrong parameters for " + R1RichPushActivity.class.getSimpleName());
            finish();
            return;
        }
        richPushId = extras.getString(R1RichPush.R1_RICH_PUSH_ID);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        setIntent(intent);
        Bundle extras = getIntent().getExtras();
        if ( extras == null ){
            Log.i(CustomPushActivity.class.getSimpleName(), "Wrong parameters for " + R1RichPushActivity.class.getSimpleName());
            finish();
            return;
        }
        richPushId = extras.getString(R1RichPush.R1_RICH_PUSH_ID);
        loadRichPush();
    }

    private void loadRichPush() {
        if (TextUtils.isEmpty(richPushId)){
            Log.i(CustomPushActivity.class.getSimpleName(), "No rich_push_id in extras");
            finish();
            return;
        }
        R1RichPushMessage message = R1RichPushManager.getR1RichPushManager().getR1RichPushMessage(this, richPushId, this);
        if ( message != null ) {
            webView = new R1RichPushWebView(this);
            webView.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            setContentView(webView);
            if ( message.getStatus() == R1RichPushMessage.RESULT_OK ) {
                webView.loadR1RichPush(message);
            } else {
                Log.i(CustomPushActivity.class.getSimpleName(), "Error while getting rich push message");
                finish();
            }
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if ( webView != null ){
            webView.onPause();
        }
        if ( !TextUtils.isEmpty(richPushId)) {
            R1RichPushManager.getR1RichPushManager().removeListener(richPushId, this);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if ( webView != null ){
            webView.onResume();
        } else {
            loadRichPush();
        }
    }

    @Override
    public void onResult(R1RichPushMessage message) {
        if ( message != null && message.getStatus() == R1RichPushMessage.RESULT_OK) {
            if (richPushId != null && richPushId.equals(message.getId())) {
                runOnUiThread( new Runnable() {
                    @Override
                    public void run() {
                        loadRichPush();
                    }
                });
            }
        } else {
            Log.i(CustomPushActivity.class.getSimpleName(), "No Connection while getting rich push message");
            finish();
        }
    }

    @Override
    public void onError(R1RichPushMessage message) {
        Log.i(CustomPushActivity.class.getSimpleName(), "Error while getting rich push message");
        finish();
    }
}

The important line in this class is

//get R1RichPushMessage from R1RichPushManager 
R1RichPushMessage message = R1RichPushManager.getR1RichPushManager().getR1RichPushMessage(this, richPushId, this);

where

R1RichPushManager.getR1RichPushManager().getR1RichPushMessage(Context context, String richPushId, R1RichPushManager.OnMessageReceivedListener receiveListener);

To make Rich Push work you have to use the following method of R1RichPushWebView:

    webView.loadR1RichPush(message);

Next register your activity in AndroidManifest.xml (do not forget service android:name="com.radiumone.emitter.richpush.R1RichPushService" because it necessary for both custom and default rich push activity).

<service android:name="com.radiumone.emitter.richpush.R1RichPushService" />


<activity
            android:name="###YOUR APPLICATION PACKAGE###.CustomRichPushActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/title_activity_rich_push"
            android:launchMode="singleTask"
            android:parentActivityName=".MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity" />
        </activity>

Then add this line just before R1Emitter.getInstance().connect(this) in your application class:

R1Emitter.getInstance().setRichPushActivity(CustomRichPushActivity.class);

Now rich push will be opened in your custom activity.

v. Inbox Initialization

The Inbox provides an easy interface to house past rich-push messages sent to your users so they can still be visible to users that have disabled push messaging or who want to come back to them later.

If you want to enable inbox functionality you need to create a fragment or an activity that shows a list of Inbox messages and listen for messages updates in the Inbox. This reference source code shows how to implement Activity in which you can show and delete messages from Inbox (this activity must be registered in your AndroidManifest.xml). This also assumes that Rich Push functionality mentioned above is already integrated.

public class R1InboxActivity extends Activity implements R1InboxManager.OnInboxUpdateListener, AdapterView.OnItemClickListener {

    // ListView for inbox messages
    private ListView listView;

    // Adapter for showing messages in listview
    private R1InboxMessageAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // creating ListView programmatically, but it can be layout from xml
        listView = new ListView(this);
        listView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        listView.setId(android.R.id.list);

        // creating Inbox adapter
        adapter = new R1InboxMessageAdapter(this);
        listView.setAdapter(adapter);

        // sets click listener for this Activity
        listView.setOnItemClickListener(this);

        // this line is for correct working delete buttons in list
        listView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

        setContentView(listView);
    }


    // method gets inbox messages and set to adapter for showing in list
    private void loadMessages() {
        final R1InboxMessage[] messages = R1InboxManager.getInboxManager().getR1InboxMessages(this);
        runOnUiThread( new Runnable() {
            @Override
            public void run() {
                if ( adapter != null ){
                    adapter.setInboxMessages(messages);
                }
            }
        });

    }

    @Override
    protected void onPause() {
        super.onPause();

        // remove inbox update listener when Activity goes to pause state
        R1InboxManager.getInboxManager().setInboxUpdateListener(null);
    }

    @Override
    protected void onStart() {
        super.onStart();

        // calls SDK onStart method
        R1Emitter.getInstance().onStart(this);
    }

    @Override
    protected void onStop() {
        super.onStart();

        // calls SDK onStop method
        R1Emitter.getInstance().onStop(this);
    }

    @Override
    protected void onResume() {
        super.onResume();

        // set inbox update listener when Activity resumes. After that all updates in inbox will invoke callback inboxUpdated() in this Activity
        R1InboxManager.getInboxManager().setInboxUpdateListener(this);

        // get actual messages after pause
        loadMessages();
    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if ( adapter != null ) {
            // get R1InboxMessage object for pressed listview position
            R1InboxMessage inboxMessage = adapter.getItem(position);

            // call inboxMessageOpen() method for correct opening and showing inbox message  
            R1InboxManager.getInboxManager().inboxMessageOpen(this, inboxMessage);
        }
    }

    @Override
    public void inboxUpdated() {
        // get actual messages after inbox updated
        loadMessages();
    }

    @Override
    public void inboxUpdateError() {
        Log.i(getClass().getSimpleName(),"Inbox update error");
    }


    // adapter for showing Inbox messages
    private class R1InboxMessageAdapter extends BaseAdapter {

        private final LayoutInflater inflater;

        // array of R1InboxMessage
        private R1InboxMessage[] listOfMessages;

        public R1InboxMessageAdapter(Context context){
            listOfMessages = new R1InboxMessage[0];
            inflater = (LayoutInflater)context.getSystemService(LAYOUT_INFLATER_SERVICE);
        }

        @Override
        public int getCount() {
            if ( listOfMessages == null ){
                return 0;
            }
            return listOfMessages.length;
        }

        @Override
        public R1InboxMessage getItem(int position) {
            return listOfMessages[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = convertView;
            ViewHolder viewHolder = null;
            if (view == null) {

                // Layout for inbox item. Will be shown further.
                view = inflater.inflate(R.layout.r1_inbox_item, null);
                viewHolder = new ViewHolder();
                viewHolder.alert = (TextView)view.findViewById(R.id.alert);
                viewHolder.title = (TextView)view.findViewById(R.id.title);
                viewHolder.dateTime = (TextView)view.findViewById(R.id.datetime);
                viewHolder.readIndicator = view.findViewById(R.id.read_indicator);

                viewHolder.delete = (Button)view.findViewById(R.id.delete_button);

                // set OnClickListener for delete button
                viewHolder.delete.setOnClickListener( new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // if tag for pressed button is an instance of R1InboxMessage you have to call inboxMessageDelete method in R1InboxManager for correct deletion of message
                        Object tag = v.getTag();
                        if ( tag instanceof R1InboxMessage ) {
                            R1InboxManager.getInboxManager().inboxMessageDelete(R1InboxActivity.this, (R1InboxMessage) tag);
                        }
                    }
                });
                view.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder)view.getTag();
            }

            R1InboxMessage message = getItem(position);

            // set Tag for delete button. This needs for knowing what message must be deleted after button pressed.
            viewHolder.delete.setTag(message);

            viewHolder.alert.setText(message.getAlert());

            viewHolder.title.setText(message.getTitle());

            viewHolder.dateTime.setText( dateTimeLocalised( message.getDateTime() ));

            // checks that message is not readed and show it 
            if ( message.getReadState() == R1RichPushMessage.READ ){
                viewHolder.readIndicator.setVisibility(View.INVISIBLE);
            } else {
                viewHolder.readIndicator.setVisibility(View.VISIBLE);
            }

            return view;
        }

        public void setInboxMessages(R1InboxMessage[] inboxMessages){
            this.listOfMessages = inboxMessages;
            notifyDataSetChanged();
        }
    }

    private static class ViewHolder {
        TextView title;
        TextView alert;
        TextView dateTime;
        Button delete;
        View readIndicator;
    }

    private String dateTimeLocalised(long dateTime){
        dateTime -= TimeZone.getDefault().getOffset(dateTime);
        return DateFormat.getDateTimeInstance().format(dateTime);
    }

}

Layout R.layout.r1_inbox_item.xml from source code above:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="?listPreferredItemHeight"
    android:orientation="horizontal"
    android:padding="8dp">

    <View
        android:id="@+id/read_indicator"
        android:layout_width="10dp"
        android:layout_height="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_gravity="center_vertical"
        android:layout_margin="8dp"
        android:background="@drawable/shape" />

    <LinearLayout
        android:id="@+id/notification_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_toEndOf="@+id/read_indicator"
        android:layout_toLeftOf="@+id/delete_button"
        android:layout_toRightOf="@+id/read_indicator"
        android:layout_toStartOf="@+id/delete_button"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:maxLines="1" />

        <TextView
            android:id="@+id/alert"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:maxLines="2" />
    </LinearLayout>

    <Button
        android:id="@+id/delete_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:focusable="false"
        android:text="Delete" />

    <TextView
        android:id="@+id/datetime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/notification_content"
        android:layout_gravity="bottom"
        android:layout_toLeftOf="@+id/delete_button"
        android:layout_toStartOf="@+id/delete_button" />


</RelativeLayout>

R1InboxMessage is an object that has the following methods to display details of inbox messages:

datetime

    inboxMessage.getDateTime()

Returns inbox message timestamp as epoch time in milliseconds

title

    inboxMessage.getTitle()

Returns inbox message title text

alert

    inboxMessage.getAlert()

Returns inbox message alert text

readState

    inboxMessage.getReadState()

Returns the read state of an inbox message, values are R1InboxMessage.READ/ R1InboxMessage.UNREAD

To display a number of unread messages use the following code:

int unread = R1InboxManager.getInboxManager().getInboxUnreadCount(context);

To be notified for realtime updates of the number of unread messages you need to register R1InboxManager.OnInboxUpdateListener. To stop this updates you need to unregister it:

R1InboxManager.getInboxManager().setInboxUpdateListener( new R1InboxManager.OnInboxUpdateListener() {
            @Override
            public void inboxUpdated() {
                // inbox updated
            }

            @Override
            public void inboxUpdateError() {
                // error occurred while inbox updated
            }
        });

vi. Deep Link Initialization

Deep linking push messages open up a designated view in an application upon user response to a system notification. To properly handle deep link push receipts, please read Android’s documentation on registering a custom URL scheme here:http://developer.android.com/guide/topics/manifest/data-element.html

vii. Segment your Audience

You can specify Tags for R1 Connect SDK to send Push Notifications for certain groups of users. You can then send Push Notifications to users with specific tags.

The maximum length of a Tag is 128 characters.

R1 Connect SDK saves Tags. You do not have to add Tags every time the application is launched.

Add a new Tag

R1Push.getInstance(context).addTag("tag");

Add multiple Tags

for ( String tag: tags) {
    R1Push.getInstance(this).addTag(tag);
}

Remove existing Tag

R1Push.getInstance(context).removeTag("tag");

Remove multiple Tags

for ( String tag: tags) {
    R1Push.getInstance(this).removeTag(tag);
}

Replace all existing Tags

R1Push.getInstance(context).setTags(Arrays.asList("tag1","tag2"));

Get all Tags

String[] allTags = R1Push.getInstance(context).getTags(context);

Automatically created Tags

date_of_launch_dd_mm_yyyy: Replace dd_mm_yyyy with the date you want to target. Date is in your account timezone.
one_time_app_users: Users who have only launched the app once

Automatically created Segments

Lapsed Users > 7 Days
Lapsed Users > 14 Days
Lapsed Users > 21 Days
Lapsed Users > 30 Days

If you are targeting devices below Android version 4.0.4, you need to also add the following permission:

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

This is in order to enable the application to use the Google Account for communication with the Google Cloud Messaging platform (used for pushed notifications). For devices running version 4.0.4 or later, a Google account is not required anymore, therefore the permission is unnecessary.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk