Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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();
    }
}

...

Example Application

RelatedDigital Demo UygulamasıExample Application