Setting the API key and API secret dynamically & receiving notifications in the background

Hi Support,

One of the major requirements in our app is that the API key and secret be set during runtime.

There's an API (say sign up API) where our existing users sign up with their credentials. The sign-up API sends the users the UrbanAirship API key and secret in response only if the credentials are right and the account is active.

The API key and secret is set during runtime in a thread as follows:

 

options = new AirshipConfigOptions.Builder()
.setDevelopmentAppKey(apiKey)
.setDevelopmentAppSecret(apiSecret)
.setChannelCaptureEnabled(true)
.setFcmSenderId("xxxxxxxxxx")
.setInProduction(false)
.setNotificationIcon(R.drawable.app_icons)
.build();

UAirship.takeOff(getApplication(), options);

UAirship.shared().getChannelCapture().enable(180, TimeUnit.SECONDS);

UAirship.shared().getPushManager().setPushEnabled(true);

UAirship.shared().getActionRegistry().unregisterAction(DeepLinkAction.DEFAULT_REGISTRY_NAME);
UAirship.shared().getActionRegistry().unregisterAction(DeepLinkAction.DEFAULT_REGISTRY_SHORT_NAME);

// Create Notification Factory
DefaultNotificationFactory defaultNotificationFactory = new DefaultNotificationFactory(getApplicationContext());

defaultNotificationFactory.setSmallIconId(R.drawable.tfa_icons);
defaultNotificationFactory.setLargeIcon(R.drawable.notification_icon);
defaultNotificationFactory.setColor(Color.rgb(12, 128, 64));
// receive only one push
defaultNotificationFactory.setConstantNotificationId(100);
defaultNotificationFactory.setTitleId(-1);

UAirship.shared().getPushManager().setNotificationFactory(defaultNotificationFactory);


It works perfectly until the app is closed. Once the app is closed, although we send push notifications, nothing is received by the mobile app. When the app is killed or running in the background (it's GUI is not active) - no notifications are received.

Please let us know if there are any other configurations that need to be enabled to get this working. 

Please note that we don't want to hardcode the API in airship config file, needs to happen at runtime.

 

Didn't find what you were looking for?

New post

Comments

0 comments

Please sign in to leave a comment.