Code Examples

JSONObject configurations = new JSONObject();
JSONObject params = new JSONObject();
JSONObject assets = new JSONObject();
JSONObject internationalization = new JSONObject();
JSONObject theme = new JSONObject();
try {
     if(getResources().getBoolean(R.bool.is_use_payload)) {
	      params.put(Personetics.PDB_PAYLOAD, config.get(Personetics.PDB_PAYLOAD));
}
params.put(Personetics.PDB_USER_ID, getResources().getString(R.string.default_user));
configurations.put(Personetics.PDB_WIDGET_TYPE, "inbox");
configurations.put(Personetics.PDB_DEVICE_TYPE, "android");
configurations.put(Personetics.PDB_SELECTOR_STRING, "#root");
configurations.put(Personetics.PDB_PARAMS, params);
if(getResources().getBoolean(R.bool.is_use_remote_assets_mode)) {
    assets.put(Personetics.PDB_BASEURL, getString(R.string.remote_assets));
    assets.put(Personetics.PDB_USEREMOTEASSETS, true);
    }
    internationalization.put(Personetics.PDB_LANGUAGE, "en");
    theme.put(Personetics.PDB_DARKMODE, false);

    config.put(Personetics.PDB_CONFIGURATIONS, configurations);
    config.put(Personetics.PDB_ASSETS, assets);
    config.put(Personetics.PDB_INTERNATIONALIZATION, internationalization);
    config.put(Personetics.PDB_THEME, theme);

    } catch (JSONException e) {
	    e.printStackTrace();
    }

    return ((MainActivity)getActivity()).getPersonetics().startWidgetWithView(getActivity(), config);

let personeticsInfo = NSMutableDictionary.init()
       let personeticsBridge = BankPersoneticsDelegate.init()
       let configurations = NSMutableDictionary.init()
       let params = NSMutableDictionary.init()
       let assets = NSMutableDictionary.init()
       let internationalization = NSMutableDictionary.init()
       let theme = NSMutableDictionary.init()

       guard let constants = NetworkManager.shared.constants else { return }

       params.setValue(constants.userName, forKey: Personetics.PDBuserId)
       configurations.setObject("inbox", forKey: Personetics.PDBWidgetType as NSCopying)
       configurations.setObject("ios", forKey: Personetics.PDBDeviceType as NSCopying)
       configurations.setObject("#root", forKey: Personetics.PDBSelectorString as NSCopying)
       internationalization.setObject(constants.appLanguage, forKey: Personetics.PDBlanguage as NSCopying)
       personeticsBridge.viewCtrl = self

       personeticsInfo.setValue(constants.protocolVersion, forKey: Personetics.PDBprotocolVersion)
       personeticsInfo.setValue(constants.webViewTag, forKey: Personetics.PDBwebViewTag)

       if constants.useRemoteAssets == true {
           assets.setObject(true, forKey: Personetics.PDBuseRemoteAssets as NSCopying)
           assets.setObject(constants.remoteUrl, forKey: Personetics.PDBbaseUrl as NSCopying)
       }
       if constants.darkMode == true {
           theme.setValue(constants.darkMode, forKey: Personetics.PDBdarkMode)
       }
       personeticsInfo.setValue(personeticsBridge, forKey: Personetics.PDBpDelegate  )
       if constants.usePayload {
           if let infoPayload = payload {
               params.setValue(infoPayload, forKey: Personetics.PDBpayload)
           } else {
               getPayloadForType(type: "inbox", requestType: "getInboxInsights", navParams: nil)
               return
           }
       }
       configurations.setObject(params, forKey: Personetics.PDBparams as NSCopying)

       personeticsInfo.setValue(configurations, forKey: Personetics.PDBconfigurations)
       personeticsInfo.setValue(assets, forKey: Personetics.PDBassets)
       personeticsInfo.setValue(internationalization, forKey: Personetics.PDBinternationalization)
       personeticsInfo.setValue(theme, forKey: Personetics.PDBtheme)

       let personetics = Personetics.init()
       personeticsBridge.personetics = personetics
       if let personeticsController = personetics.startWidget(personeticsInfo: personeticsInfo) as? UIViewController {
           personeticsController.updateViewConstraints()
           self.navigationController?.pushViewController(personeticsController, animated: true)
       }