1

I'm developing an Android app using the MobilePush SDK. I believe I'm configuring the SDK ok in the code, but I don't see any Contacts records show up on the server.

Here is my onCreate() method of my Application class:

@Override
public void onCreate() {
super.onCreate();
try {
ETPush.readyAimFire(this, ET_APP_ID, ET_APP_TOKEN, false, false, false);

ETPush pushManager = ETPush.pushManager();
pushManager.setGcmSenderID(GOOGLE_PROJECT_ID);
//A good practice is to add the versionName of your app from the manifest as a tag
//so you can target specific app versions with a push message later if necessary.
String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
pushManager.addTag(versionName);
} 
catch (ETException e) {
Log.e(TAG, e.getMessage(), e);
}
catch (NameNotFoundException e) {
Log.e(TAG, e.getMessage(), e);
}

}

Here is my main Activity onCreate() method where I call enablePush(). It's my understanding that calling this method is all I need to do for a Registration to happen on the server, correct?

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
try {
If(!ETPush.pushManager().isPushEnabled()) {
ETPush.pushManager().enablePush(this);
}
}
catch(ETException e) {
Log.e(TAG, e.getMessage(), e);
}
}
2

Eddie,

Your code looks good as long as your constants for ET_APP_ID, ET_APP_TOKEN, and GOOGLE_PROJECT_ID are all correct. Step 1 is to make sure there are no copy/paste mistakes there.

If that all checks out, you should next check your AndroidManifest.xml file and ensure it has all of the required permissions, Receivers, and Services. Also ensure your project includes the necessary JAR dependencies. You can review this section of the documentation to check your setup:

https://code.exacttarget.com/mobilepush/integrating-mobilepush-sdk-your-android-mobile-app#Bootstrap

Ensure that you've waited 15 minutes after making your enablePush() call. These are batch processed on the server, so it may sometimes take a few minutes to show up on the marketing cloud website.

Finally, another bit of code you can add to figure out what's going on is to use the EventBus. In your main Activity, add the following code to your onCreate() and onDestroy() methods.

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  ...
  EventBus.getDefault().register(this);
  ...
}

@Override
public void onDestroy() {
  super.onDestroy();
  ...
  EventBus.getDefault().unregister(this);
  ...
}

Then add the following functions. They should be called if either you get a successful registration on the server or some error occurs.

public void onEvent(final RegistrationEvent registrationEvent) {
  Log.d(TAG, "EtAppId: " + registrationEvent.getEtAppId());
  Log.d(TAG, "DeviceId: " + registrationEvent.getDeviceId());
  Log.d(TAG, "DeviceToken: "+registrationEvent.getDeviceToken());
}

public void onEvent(final ServerErrorEvent serverErrorEvent) {
  String errorJson = JSONUtil.objectToJson(serverErrorEvent);
  Log.e(TAG, "ServerErrorEvent: "+ errorJson);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.