This document explains how to add the Appoxee code to your application code
Source code integration
1. In the Application class of your android project, add following code
Code Block | ||||
---|---|---|---|---|
| ||||
public class AppoxeeTestApp extends Application {
...
@Override
public void onCreate() {
super.onCreate();
...
AppoxeeOptions opt = new AppoxeeOptions();
opt.sdkKey = SDK_KEY;
opt.googleProjectId = GOOGLE_PROJECT_ID;
Appoxee.engage(this, opt);
...
}
...
} |
pass your SDK Key and google project Id, SDK key is present in your Appoxee Application dashboard. Add application in Android manifest file.
Code Block | ||||
---|---|---|---|---|
| ||||
public class MyPushBroadcastReceiver extends PushDataReceiver {
@Override
public void onPushReceived(PushData pushData) {
Log.d("APX", "Push received " + pushData);
}
@Override
public void onPushOpened(PushData pushData) {
Log.d("APX", "Push opened " + pushData);
}
@Override
public void onPushDismissed(PushData pushData) {
Log.d("APX", "Push dismissed " + pushData);
}
} |
3. For Custom layout Notifications, add this code in Application class, before calling Appoxee.engage method
Code Block | ||||
---|---|---|---|---|
| ||||
//add this only for the custom layout notifications
CustomXmlLayoutNotificationCreator.Builder builder = new CustomXmlLayoutNotificationCreator.Builder(this);
builder.setLayoutResource(R.layout.custom_notification_layout) //your custom notification layout
.setIconResourceId(R.id.appoxee_default_push_icon)
.setTextResourceId(R.id.appoxee_default_push_message)
.setTitleResourceId(R.id.appoxee_default_push_subject)
.setTimeResourceId(R.id.appoxee_default_push_hour);
opt.customNotificationCreator = new CustomXmlLayoutNotificationCreator(builder);
Appoxee.engage(this, opt); |
4. If prompted with an error, add this "Import" command to enable Appoxee SDK usage:
Code Block | ||
---|---|---|
| ||
import com.appoxee.Appoxee; |
5. Add a callback to appoxee finished all initialization, the callback will be called when Appoxee is up and ready, or if server hand-shaking is failed.
Code Block | ||||
---|---|---|---|---|
| ||||
Appoxee.instance().addInitListener(new Appoxee.OnInitCompletedListener() {
@Override
public void onInitCompleted(boolean successful, Exception failReason) {
}
});
|
6. Another way to check the initialization finish or not is to use following method:
Code Block | ||
---|---|---|
| ||
Appoxee.instance().isReady(); |
return true when appoxee has finished launching.
Advanced Options (Deep-linking)
Deep Link / URL Scheme in Appoxee & Android, add following code in the manifest file, if you wants to open any other activity from push notification click.
Code Block | ||||
---|---|---|---|---|
| ||||
<activity android:name="com.appoxee.example.AnyActivity" >
<!-- Add the Intent Filter for activity needed to be URLScheme compatible -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://pushnotification" -->
<data android:scheme="example"
android:host="pushnotification" />
</intent-filter>
</activity> |