Ejemplo n.º 1
0
  @Export
  public JsFacade(String[] endpoints) {

    provider = (JsFileSystemProvider) Storage.getFileSystemRuntime();

    String clientName = IdentityUtils.getClientName();
    String uniqueId = IdentityUtils.getUniqueId();

    ConfigurationBuilder configuration = new ConfigurationBuilder();
    configuration.setApiConfiguration(
        new ApiConfiguration(APP_NAME, APP_ID, APP_KEY, clientName, uniqueId));
    configuration.setPhoneBookProvider(new JsPhoneBookProvider());
    configuration.setNotificationProvider(new JsNotificationsProvider());

    // Is Web application
    configuration.setPlatformType(PlatformType.WEB);

    // Device Category
    // Only Desktop is supported for JS library
    configuration.setDeviceCategory(DeviceCategory.DESKTOP);

    // Adding endpoints
    for (String endpoint : endpoints) {
      configuration.addEndpoint(endpoint);
    }

    messenger = new JsMessenger(configuration.build());

    Log.d(TAG, "JsMessenger created");
  }
Ejemplo n.º 2
0
  private Core(Application application) throws IOException, JSONException {

    AndroidContext.setContext(application);

    // Integrations
    //noinspection ConstantConditions
    JSONObject config =
        new JSONObject(new String(readAll(application.getAssets().open("app.json"))));
    hockeyToken = config.optString("hockeyapp");

    if (config.optString("mint") != null && !config.optString("mint").equals("null")) {
      Mint.disableNetworkMonitoring();
      Mint.initAndStartSession(application, config.getString("mint"));
    }
    Fresco.initialize(application);

    // Keep Alive
    application.startService(new Intent(application, KeepAliveService.class));

    // Helpers
    AppContext.setContext(application);

    this.smileProcessor = new SmileProcessor(application);
    this.smileProcessor.loadEmoji();

    //        AndroidConfigurationBuilder builder = new AndroidConfigurationBuilder(
    //                application.getResources().getString(R.string.app_locale),
    //                application);
    //        builder.setPhoneBookProvider(new AndroidPhoneBook());
    //        builder.setNotificationProvider(new AndroidNotifications(AppContext.getContext()));
    //        JSONArray endpoints = config.getJSONArray("endpoints");
    //        for (int i = 0; i < endpoints.length(); i++) {
    //            builder.addEndpoint(endpoints.getString(i));
    //        }
    //        builder.setEnableContactsLogging(true);
    //        builder.setEnableNetworkLogging(true);
    //        builder.setEnableFilesLogging(true);
    //        //noinspection ConstantConditions
    //        if (config.optString("mixpanel") != null) {
    //            builder.setAnalyticsProvider(new AndroidMixpanelAnalytics(AppContext.getContext(),
    // config.getString("mixpanel")));
    //        }
    //        builder.setDeviceCategory(DeviceCategory.MOBILE);
    //        builder.setAppCategory(AppCategory.ANDROID);
    //
    //        builder.setApiConfiguration(new ApiConfiguration(
    //                BuildConfig.VERSION_TITLE,
    //                API_ID,
    //                API_KEY,
    //                getDeviceName(),
    //                AppContext.getContext().getPackageName() + ":" + Build.SERIAL));
    //
    //        builder.setMaxDelay(MAX_DELAY);

    ConfigurationBuilder builder = new ConfigurationBuilder();
    JSONArray endpoints = config.getJSONArray("endpoints");
    for (int i = 0; i < endpoints.length(); i++) {
      builder.addEndpoint(endpoints.getString(i));
    }
    builder.setPhoneBookProvider(new AndroidPhoneBook());
    builder.setNotificationProvider(new AndroidNotifications(AppContext.getContext()));
    builder.setDeviceCategory(DeviceCategory.MOBILE);
    builder.setAppCategory(AppCategory.ANDROID);
    builder.setApiConfiguration(
        new ApiConfiguration(
            BuildConfig.VERSION_TITLE,
            API_ID,
            API_KEY,
            getDeviceName(),
            AppContext.getContext().getPackageName() + ":" + Build.SERIAL));
    this.messenger = new AndroidMessenger(AppContext.getContext(), builder.build());
  }