a push notification android sdk
allprojects {
repositories {
jcenter()
google()
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven {
name = "notif_sdk"
url = uri("https://maven.pkg.github.com/FanapSoft/pod-notif-android-sdk")
credentials {
username = System.getenv('GITHUB_USER')
password = System.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')
}
}
}
}
implementation("ir.fanap.sdk_notif:sdk_notif:0.0.6.4")
pushSdk = new PushSdk.Builder()
.setContext(MainActivity.this)
.setAppId(appId)
.setHandleNotification(false)
.setResponseListener(new ResponseListener() {
@Override
public void onSubscribe(JSONObject jsonObject) {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnSubmitWithoutLogin.stopLoading();
lblResponse.setText(jsonObject.optString("fcmToken"));
lblResponse.setTextColor(Color.GREEN);
}
});
}
@Override
public void onUnsubscribe() {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnExit.stopLoading();
lblResponse.setText("Logout!!!");
lblResponse.setTextColor(Color.GREEN);
}
});
}
@Override
public void onError(Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnExit.stopLoading();
btnSubmitWithoutLogin.stopLoading();
lblResponse.setText(e.getMessage());
lblResponse.setTextColor(Color.RED);
}
});
}
})
.build();
pushSdk = new PushSdk.Builder()
.setContext(MainActivity.this)
.setAppId(appId)
.setSsoId(ssoId)
.setHandleNotification(false)
.setResponseListener(new ResponseListener() {
@Override
public void onSubscribe(JSONObject jsonObject) {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnSubmitWithLogin.stopLoading();
lblResponse.setText(jsonObject.optString("fcmToken"));
lblResponse.setTextColor(Color.GREEN);
}
});
}
@Override
public void onUnsubscribe() {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnExit.stopLoading();
lblResponse.setText("Logout!!!");
lblResponse.setTextColor(Color.GREEN);
}
});
}
@Override
public void onError(Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnExit.stopLoading();
btnSubmitWithLogin.stopLoading();
lblResponse.setText(e.getMessage());
lblResponse.setTextColor(Color.RED);
}
});
}
})
.build();
You can get data from notification and parse it
pushSdk.setNotificationListener(new NotificationListener() {
@Override
public void getNotification(JSONObject object) {
//TODO: get notification data and customize it, then show notification
}
});