1

I've integrated the JB SDK v4.3.1 in my android app, and followed the integration tutorial from here, and to use the Open Direct feature from here.

My custom application code is as follows:

package br.com.package;

import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.exacttarget.etpushsdk.ETException;
import com.exacttarget.etpushsdk.ETNotificationBuilder;
import com.exacttarget.etpushsdk.ETNotifications;
import com.exacttarget.etpushsdk.ETPush;
import com.exacttarget.etpushsdk.ETPushConfig;
import com.exacttarget.etpushsdk.event.ReadyAimFireInitCompletedEvent;
import com.exacttarget.etpushsdk.util.EventBus;

import br.com.package.JB_SDK.CustomLandingPageActivity;

public class CustomApplication extends Application {

public void onCreate() {
    super.onCreate();

    AppContext.init(this);

    //TODO remove
    CacheStorageSpace.init(getApplicationContext());
    //TODO remove
    InternalStorageSpace.init(getApplicationContext());

    ResourcesUtils.setContext(this);

    EventBus.getInstance().register(this);

    try {
        // ETPush configuration
        ETPush.readyAimFire(new ETPushConfig.Builder(this)
                .setEtAppId(BuildConfig.ET_APP_ID)
                .setAccessToken(BuildConfig.ET_ACCESS_TOKEN)
                .setGcmSenderId(BuildConfig.GCM_SENDER_ID)
                .setAnalyticsEnabled(true)
                .setWamaEnabled(true)
                .setCloudPagesEnabled(true)
                .build());
    }catch (ETException e) {
        e.printStackTrace();
    }
}

public void onEvent(final ReadyAimFireInitCompletedEvent event) {

    try {

        if (ETPush.getLogLevel() <= Log.DEBUG) {
            Log.i("ReadyAimFire", "ReadyAimFireInitCompletedEvent started.");
        }

        if (event.isReadyAimFireReady()) {

            ETPush.getInstance().setOpenDirectRecipient(CustomLandingPageActivity.class);
        }

    } catch (ETException e) {
        e.printStackTrace();
    }
}
}

The subscription is working fine and pushes are arriving with a good payload. The problem is, when clicking the notification the next behaviour is weird, and depends on the state of the app:

  1. if the app is not running (killed in the applications menu "square"), and the notification is opened it opens the landing page but the Activity is the default one, the name of the activity is "Landing Page";

  2. sometimes even when the app is dead the landing page is loaded correctly, and the name of the activity is "My app name" as it should be. But, in this case, every other notification have their Open Direct url ignored and no landing page is showed, just the first one;

  3. if the app is opened by clicking the icon, as normal, the behaviour is the expected, and every notification opens the app in the good landing page;

I'd want to know if I did something wrong in my integration and if this have happened with someone else.

1 Answer 1

1

Try setting your OpenDirect class in the ReadyAimFire Builder rather than doing it in the onEvent() method. I suspect the landing page is being launched before the application class has fully finished and we're defaulting to our internal handler.

ETPush.readyAimFire(new ETPushConfig.Builder(this)
                .setEtAppId(BuildConfig.ET_APP_ID)
                .setAccessToken(BuildConfig.ET_ACCESS_TOKEN)
                .setGcmSenderId(BuildConfig.GCM_SENDER_ID)
                .setAnalyticsEnabled(true)
                .setWamaEnabled(true)
                .setCloudPagesEnabled(true)
                .setOpenDirectRecipientClass(CustomLandingPageActivity.class)
                .build());
3
  • Wow, I did not know about the existence of this builder method. That could work, I will test this soon. The doc should point that as primary implementation for Open Direct.
    – Felipe Jun
    May 5, 2016 at 19:28
  • That does seem to work, I must override the setNotificationLauchIntent anyways to set the CLEAR_TOP flag, but this is clearly a bug that should have some attention.
    – Felipe Jun
    May 5, 2016 at 19:39
  • I will file the "CLEAR_TOP" as a bug. I have been deprecating the helper methods in favor of the ETPushConfig.Builder() methods. Stay tuned. You'll soon have a callback interface to know when ReadyAimFire has finished initializing ;)
    – Bill Mote
    May 5, 2016 at 19:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .