...
Info |
---|
init() metodunun Application sınıfının içerisinde çağırılması önerilir. Application sınıfını AndroidManifest.xml dosyasında <application tag ı içerisinde android:name ile tanımlamayı unutmayınız. |
init metodu 4 zorunlu parametre (hepsi zorunlu) almaktadır. SDK yı aşağıdaki gibi init edebilirsiniz.
Kotlin
Code Block | ||
---|---|---|
| ||
RelatedDigital.init( context = applicationContextcontext, organizationId = "buraya organization id nizi yazınız", organizationId profileId = "buraya organizationprofile id nizi yazınız", dataSource = "buraya datasource değerini yazınız" ) |
Java
Code Block | ||
---|---|---|
| ||
RelatedDigital.init( profileId =context, "buraya profileorganization id nizi yazınız", "buraya profile id dataSource =nizi yazınız", "buraya datasource değerini yazınız" ); |
Bu bilgilere RMC paneli üzerinden ulaşabilirsiniz.
...
RelatedDigital SDK 3 ayrı modülden oluşmaktadır :
Push Notification Modülü (Euromessage)
In-App Notification Modülü (Visilabs)
Geofence Modülü
Kullanmak istediğiniz modülleri aşağıdaki gibi etkinleştirmeniz gerekmektedir.
...
AndroidManifest.xml
Code Block | ||
---|---|---|
| ||
<application android:name=".MainApplication" |
MainApplication.ktKotlin
Code Block | ||
---|---|---|
| ||
class MainApplication : Application() { override fun onCreate() { super.onCreate() // RelatedDigital SDK nın init edilmesi RelatedDigital.init( context = applicationContextcontext, organizationId = "organizationIdDeğeri", profileId = "profileIdDeğeri", dataSource = "dataSourceDeğeri") // In-App Notification Modülünün etkinleştirilmesi RelatedDigital.setIsInAppNotificationEnabled( context = applicationContextcontext, isInAppNotificationEnabled = true ) // Push Notification Modülünün Etkinleştirilmesi if(GoogleUtils.checkPlayService(this)) { getFirebaseToken() } else { getHuaweiToken() } // Geofence Modülünün Etkinleştirilmesi RelatedDigital.setIsGeofenceEnabled( context = applicationContextcontext, isGeofenceEnabled = true ) } private fun getFirebaseToken(){ FirebaseMessaging.getInstance().token .addOnCompleteListener(OnCompleteListener { task -> if (!task.isSuccessful) { Log.e("Firebase Token : ", "Getting the token failed!!!") return@OnCompleteListener } val token = task.result // Push Notification Modülünün Etkinleştirilmesi RelatedDigital.setIsPushNotificationEnabled( context = applicationContextcontext, isPushNotificationEnabled = true, googleAppAlias = "googleAppAliasDeğeri", huaweiAppAlias = "huaweiAppAliasDeğeri", token = token ) }) } private fun getHuaweiToken() { object : Thread() { override fun run() { try { val appId = AGConnectOptionsBuilder().build(applicationContext) .getString("client/app_id") val token = HmsInstanceId.getInstance(applicationContext).getToken(appId, "HCM") if (TextUtils.isEmpty(token) || token == null) { Log.e("Huawei Token : ", "Empty token!!!") return } Log.i("Huawei Token", "" + token) // Push Notification Modülünün Etkinleştirilmesi RelatedDigital.setIsPushNotificationEnabled( context = applicationContextcontext, isPushNotificationEnabled = true, googleAppAlias = "googleAppAliasDeğeri", huaweiAppAlias = "huaweiAppAliasDeğeri", token = token ) } catch (e: ApiException) { Log.e("Huawei Token", "Getting the token failed! $e") } } }.start() } } |
Push Notification Modülü (Euromessage)
Bildirim Alanın Özelleştirilmesi
Bu modül mobil bildirim kampanyalarınız içindir. Yukarda belirtildiği gibi etkinleştirilmesi gerekmektedir.
RelatedDigital.setIsPushNotificationsEnabled() metodu 5 zorunlu, 8 opsiyonel parametrede almaktadır.
Zorunlu parametreler:
context: Context
isPushNotificationEnabled: Boolean
googleAppAlias: String
huaweiAppAlias: String
token: String
Opsiyonel Parametreler
notificationSmallIcon: Int
notificationSmallIconDarkMode: Int
isNotificationLargeIcon: Boolean
notificationLargeIcon: Int
notificationLargeIconDarkMode
notificationPushIntent: String
notificationChannelName: String
notificationColor: String
...
Opsiyonel Parametreler
...
Açıklama
...
notificationSmallIcon
...
Status Bar’da ve bildirim alanının sol üstünde görüntülenecek ikonu girmek içindir. Projenizdeki herhangi bir resource un id sini vermeniz gerekmektedir.
Eğer değer girilmezse uygulamanızın simgesi kullanılır.
...
notificationSmallIconDarkMode
...
Cihaz koyu temadayken görünecek notificationSmallIcon
değerini girmek içindir.
Eğer değer girilmezse uygulamanızın simgesi kullanılır.
...
isNotificationLargeIcon
...
Bildirim alanının sağında bir ikon bulunup bulunmamasına karar vermek içindir.
true → bulunur
false → bulunmaz
Eğer değer girilmezse büyük ikon kullanılmaz.(false)
...
notificationLargeIcon
...
Bildirim alanının sağında görünecek büyük ikonu girmek içindir. Projenizdeki herhangi bir resource un id sini vermeniz gerekmektedir.
Eğer değer girilmezse ve isNotificationLargeIcon
true ise uygulamanızın simgesi kullanılır.
...
notificationLargeIconDarkMode
...
Cihaz koyu temadayken görünecek notificationLargeIcon
değerini girmek içindir.
Eğer değer girilmezse ve isNotificationLargeIcon
true ise uygulamanızın simgesi kullanılır.
...
notificationPushIntent
...
Bildirime tıklandığında açılacak Activity'e karar vermek içindir. Burda Activity'nin tam yolunun girilmesi gerekmektedir.
Eğer değer girilmezse uygulamanızın başlatıcı aktivitesine (launcher activity) yönlenecektir.
...
notificationChannelName
...
Bildirim kanalına verilecek ismi girmek içindir.
Eğer değer girilmezse uygulamanızın ismi kullanılır.
...
notificationColor
...
Bildirim alanında kullanılacak accent color değerini girmek içindir.
Tüm parametreleri içeren örnek bir kullanım aşağıdaki gibidir.
Code Block | ||
---|---|---|
| ||
RelatedDigital.setIsPushNotificationEnabled(
context = applicationContext,
isPushNotificationEnabled = true,
googleAppAlias = Constants.GOOGLE_APP_ALIAS,
huaweiAppAlias = Constants.HUAWEI_APP_ALIAS,
token = token,
notificationSmallIcon = R.drawable.text_icon,
notificationSmallIconDarkMode = R.drawable.text_icon_dark_mode,
isNotificationLargeIcon = true,
notificationLargeIcon = R.mipmap.ic_launcher,
notificationLargeIconDarkMode = R.mipmap.ic_launcher,
notificationPushIntent = "com.relateddigital.androidexampleapp.PushNotificationActivity",
notificationChannelName = "relateddigital-android-test",
notificationColor = "#d1dbbd"
) |
...
Java
Code Block | ||
---|---|---|
| ||
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// RelatedDigital SDK nın init edilmesi
RelatedDigital.init(
context,
"organizationIdDeğeri",
"profileIdDeğeri",
"dataSourceDeğeri");
// In-App Notification Modülünün etkinleştirilmesi
RelatedDigital.setIsInAppNotificationEnabled(
context,
true
);
// Push Notification Modülünün Etkinleştirilmesi
if(GoogleUtils.checkPlayService(this)) {
getFirebaseToken();
} else {
getHuaweiToken();
}
// Geofence Modülünün Etkinleştirilmesi
RelatedDigital.setIsGeofenceEnabled(
context,
true
);
}
private void getFirebaseToken(){
FirebaseMessaging.getInstance().token
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
Log.e("Firebase Token : ", "Getting the token failed!!!");
return;
}
String token = task.getResult();
//Push Notification Modülünün Etkinleştirilmesi
RelatedDigital.setIsPushNotificationEnabled(
context,
true,
"googleAppAliasDeğeri",
"huaweiAppAliasDeğeri",
token
);
}
});
}
private void getHuaweiToken() {
new Thread() {
@Override
public void run() {
try {
String appId = AGConnectServicesConfig.fromContext(getApplicationContext()).getString("client/app_id");
final String token = HmsInstanceId.getInstance(getApplicationContext()).getToken(appId, "HCM");
// Push Notification Modülünün Etkinleştirilmesi
RelatedDigital.setIsPushNotificationEnabled(
context,
true,
"googleAppAliasDeğeri",
"huaweiAppAliasDeğeri",
token);
} catch (ApiException e) {
Log.e("Huawei Token", "Getting the token failed! " + e);
}
}
}.start();
}
} |