Table of Contents | ||||
---|---|---|---|---|
|
Initializing the SDK
...
Info |
---|
It is recommended to call 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. |
...
method in Application class. Please, do not forget to define the Application class in AndroidManifest.xml file with android:name attribute under <application tag. |
init() method has 4 mandatory parameters. You can initialize the SDK as shown below:
Kotlin
Code Block | ||
---|---|---|
| ||
RelatedDigital.init( context = context, organizationId = "buraya "organization idID nizi yazınızvalue", profileId = "buraya profile idID nizi yazınızvalue", dataSource = "burayadata datasourcesource değerini yazınızvalue" ) |
Java
Code Block | ||
---|---|---|
| ||
RelatedDigital.init( context, "buraya organization idID nizi yazınızvalue", "buraya profile idID nizi yazınızvalue", "burayadata datasourcesource değerini yazınızvalue" ); |
Bu bilgilere RMC paneli üzerinden ulaşabilirsinizYou can reach this information on RMC panel.
...
...
Enabling the modules that will be used
RelatedDigital SDK 3 ayrı modülden oluşmaktadır consists of 3 different modules:
Push Notification ModülüModule
In-App Notification ModülüGeofence ModülüModule
Geofencing Module
It is required to enable the modules that are going to be used as shown below:
Kullanmak istediğiniz modülleri aşağıdaki gibi etkinleştirmeniz gerekmektedir.
...
Info |
---|
It is recommended to enable the modules in Application class. You can find an example Application class that initializes the SDK and enables the all modules below. |
AndroidManifest.xml
Code Block | ||
---|---|---|
| ||
<application android:name=".MainApplication" |
Kotlin
Code Block | ||
---|---|---|
| ||
class MainApplication : Application() { override fun onCreate() { super.onCreate() // RelatedDigital SDK nın init edilmesi // Init the SDK RelatedDigital.init( context = context, organizationId = "organizationIdDeğeriorganizationIdValue", profileId = "profileIdDeğeriprofileIdValue", dataSource = "dataSourceDeğeridataSourceValue") // Enable In-App Notification ModülününModule etkinleştirilmesi RelatedDigital.setIsInAppNotificationEnabled( context = context, isInAppNotificationEnabled = true ) // Enable Push Notification ModülününModule Etkinleştirilmesi if(GoogleUtils.checkPlayService(this)) { getFirebaseToken() } else { getHuaweiToken() } // GeofenceEnable ModülününGeofencing EtkinleştirilmesiModule RelatedDigital.setIsGeofenceEnabled( context = context, 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 // Enable Push Notification Modülünün EtkinleştirilmesiModule RelatedDigital.setIsPushNotificationEnabled( context = context, isPushNotificationEnabled = true, googleAppAlias = "googleAppAliasDeğerigoogleAppAliasValue", huaweiAppAlias = "huaweiAppAliasDeğerihuaweiAppAliasValue", 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) // Enable Push Notification ModülününModule Etkinleştirilmesi RelatedDigital.setIsPushNotificationEnabled( context = context, isPushNotificationEnabled = true, googleAppAlias = "googleAppAliasDeğerigoogleAppAliasValue", huaweiAppAlias = "huaweiAppAliasDeğerihuaweiAppAliasValue", token = token ) } catch (e: ApiException) { Log.e("Huawei Token", "Getting the token failed! $e") } } }.start() } } |
Java
Code Block | |
---|---|
| |
| |
public class MainApplication extends Application { @Override public void onCreate() { super.onCreate(); // Init RelatedDigitalthe SDK nın init edilmesi RelatedDigital.init( context, "organizationIdDeğeriorganizationIdValue", "profileIdDeğeriprofileIdValue", "dataSourceDeğeridataSourceValue"); // Enable In-App Notification Modülünün etkinleştirilmesiModule RelatedDigital.setIsInAppNotificationEnabled( context, true ); // Enable Push Notification ModülününModule Etkinleştirilmesi if(GoogleUtils.checkPlayService(this)) { getFirebaseToken(); } else { getHuaweiToken(); } // GeofenceEnable ModülününGeofencing EtkinleştirilmesiModule 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(); // Enable Push Notification Modülünün EtkinleştirilmesiModule RelatedDigital.setIsPushNotificationEnabled( context, true, "googleAppAliasDeğerigoogleAppAliasValue", "huaweiAppAliasDeğerihuaweiAppAliasValue", 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"); // Enable Push Notification Modülünün EtkinleştirilmesiModule RelatedDigital.setIsPushNotificationEnabled( context, true, "googleAppAliasDeğerigoogleAppAliasValue", "huaweiAppAliasDeğerihuaweiAppAliasValue", token); } catch (ApiException e) { Log.e("Huawei Token", "Getting the token failed! " + e); } } }.start(); } } |
...