@Test public void getAttributes() { ShadowMarketingCloudSdk.isReady(true); Map<String, String> attrs = Collections.singletonMap("Name", "Tester"); when(registrationManager.getAttributes()).thenReturn(attrs); reactModule.getAttributes(promise); verify(registrationManager).getAttributes(); ArgumentCaptor<ShadowArguments.TestWritableMap> mapCaptor = ArgumentCaptor.forClass(ShadowArguments.TestWritableMap.class); verify(promise).resolve(mapCaptor.capture()); ShadowArguments.TestWritableMap map = mapCaptor.getValue(); assertEquals("Tester", map.getString("Name")); }
@ReactMethod public void getAttributes(Promise promise) { handleAction(new PromiseAction(promise) { @Override void execute(MarketingCloudSdk sdk, @NonNull Promise promise) { Map<String, String> attributes = sdk.getRegistrationManager().getAttributes(); WritableMap writableMap = Arguments.createMap(); if (!attributes.isEmpty()) { for (Map.Entry<String, String> entry : attributes.entrySet()) { writableMap.putString(entry.getKey(), entry.getValue()); } } promise.resolve(writableMap); } }); }
RNMarketingCloudSdkModule extends ReactContextBaseJavaModule { @ReactMethod public void getAttributes(Promise promise) { handleAction(new PromiseAction(promise) { @Override void execute(MarketingCloudSdk sdk, @NonNull Promise promise) { Map<String, String> attributes = sdk.getRegistrationManager().getAttributes(); WritableMap writableMap = Arguments.createMap(); if (!attributes.isEmpty()) { for (Map.Entry<String, String> entry : attributes.entrySet()) { writableMap.putString(entry.getKey(), entry.getValue()); } } promise.resolve(writableMap); } }); } }
RNMarketingCloudSdkModule extends ReactContextBaseJavaModule { @ReactMethod public void getAttributes(Promise promise) { handleAction(new PromiseAction(promise) { @Override void execute(MarketingCloudSdk sdk, @NonNull Promise promise) { Map<String, String> attributes = sdk.getRegistrationManager().getAttributes(); WritableMap writableMap = Arguments.createMap(); if (!attributes.isEmpty()) { for (Map.Entry<String, String> entry : attributes.entrySet()) { writableMap.putString(entry.getKey(), entry.getValue()); } } promise.resolve(writableMap); } }); } RNMarketingCloudSdkModule(ReactApplicationContext reactContext); }
RNMarketingCloudSdkModule extends ReactContextBaseJavaModule { @ReactMethod public void getAttributes(Promise promise) { handleAction(new PromiseAction(promise) { @Override void execute(MarketingCloudSdk sdk, @NonNull Promise promise) { Map<String, String> attributes = sdk.getRegistrationManager().getAttributes(); WritableMap writableMap = Arguments.createMap(); if (!attributes.isEmpty()) { for (Map.Entry<String, String> entry : attributes.entrySet()) { writableMap.putString(entry.getKey(), entry.getValue()); } } promise.resolve(writableMap); } }); } RNMarketingCloudSdkModule(ReactApplicationContext reactContext); @Override String getName(); @ReactMethod void isPushEnabled(Promise promise); @ReactMethod void enablePush(); @ReactMethod void disablePush(); @ReactMethod void getSystemToken(Promise promise); @ReactMethod void getAttributes(Promise promise); @ReactMethod void setAttribute(final String key, final String value); @ReactMethod void clearAttribute(final String key); @ReactMethod void addTag(final String tag); @ReactMethod void removeTag(final String tag); @ReactMethod void getTags(Promise promise); @ReactMethod void setContactKey(final String contactKey); @ReactMethod void getContactKey(final Promise promise); @ReactMethod void enableVerboseLogging(); @ReactMethod void disableVerboseLogging(); @ReactMethod void logSdkState(); }
RNMarketingCloudSdkModule extends ReactContextBaseJavaModule { @ReactMethod public void getAttributes(Promise promise) { handleAction(new PromiseAction(promise) { @Override void execute(MarketingCloudSdk sdk, @NonNull Promise promise) { Map<String, String> attributes = sdk.getRegistrationManager().getAttributes(); WritableMap writableMap = Arguments.createMap(); if (!attributes.isEmpty()) { for (Map.Entry<String, String> entry : attributes.entrySet()) { writableMap.putString(entry.getKey(), entry.getValue()); } } promise.resolve(writableMap); } }); } RNMarketingCloudSdkModule(ReactApplicationContext reactContext); @Override String getName(); @ReactMethod void isPushEnabled(Promise promise); @ReactMethod void enablePush(); @ReactMethod void disablePush(); @ReactMethod void getSystemToken(Promise promise); @ReactMethod void getAttributes(Promise promise); @ReactMethod void setAttribute(final String key, final String value); @ReactMethod void clearAttribute(final String key); @ReactMethod void addTag(final String tag); @ReactMethod void removeTag(final String tag); @ReactMethod void getTags(Promise promise); @ReactMethod void setContactKey(final String contactKey); @ReactMethod void getContactKey(final Promise promise); @ReactMethod void enableVerboseLogging(); @ReactMethod void disableVerboseLogging(); @ReactMethod void logSdkState();  }