Skip to content

Commit e67c005

Browse files
add a new API in Core - resetIdentities (#63) (#64)
* add a new API in Core -? resetIdentities * update core package version to alpha.2
1 parent a1547ef commit e67c005

File tree

11 files changed

+1040
-974
lines changed

11 files changed

+1040
-974
lines changed

apps/AEPSampleApp/extensions/Core.js

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,64 +14,65 @@ governing permissions and limitations under the License.
1414
*/
1515

1616
import React from 'react';
17-
import {Button, Text, View, ScrollView, NativeModules} from 'react-native';
18-
import {AEPCore, AEPLifecycle, AEPSignal, AEPMobileLogLevel, AEPMobilePrivacyStatus, AEPMobileVisitorAuthenticationState, AEPVisitorID, AEPExtensionEvent} from '@adobe/react-native-aepcore';
17+
import { Button, Text, View, ScrollView, NativeModules } from 'react-native';
18+
import { AEPCore, AEPLifecycle, AEPSignal, AEPMobileLogLevel, AEPMobilePrivacyStatus, AEPMobileVisitorAuthenticationState, AEPVisitorID, AEPExtensionEvent } from '@adobe/react-native-aepcore';
1919
import styles from '../styles/styles';
2020

2121
export default Core = ({ navigation }) => {
2222

2323
return (
2424
<View style={styles.container}>
25-
<ScrollView contentContainerStyle={{ marginTop: 75 }}>
25+
<ScrollView contentContainerStyle={{ marginTop: 75 }}>
2626
<Button onPress={() => navigation.goBack()} title="Go to main page" />
2727
<Text style={styles.welcome}>Core</Text>
28-
<Button title="extensionVersion()" onPress={coreExtensionVersion}/>
29-
<Button title="updateConfiguration" onPress={updateConfiguration}/>
30-
<Button title="setPrivacyStatus(OptIn)" onPress={setPrivacyOptIn}/>
31-
<Button title="getPrivacyStatus()" onPress={getPrivacyStatus}/>
32-
<Button title="log(...)" onPress={log}/>
33-
<Button title="setLogLevel(AEPMobileLogLevel.VERBOSE)" onPress={setLogLevel}/>
34-
<Button title="getLogLevel()" onPress={getLogLevel}/>
35-
<Button title="setPushIdentifier()" onPress={setPushIdentifier}/>
36-
<Button title="setAdvertisingIdentifier()" onPress={setAdvertisingIdentifier}/>
37-
<Button title="getSdkIdentities()" onPress={getSdkIdentities}/>
38-
<Button title="collectPii()" onPress={collectPii}/>
39-
<Button title="trackAction()" onPress={trackAction}/>
40-
<Button title="trackState()" onPress={trackState}/>
41-
<Button title="dispatchEvent()" onPress={dispatchEvent}/>
42-
<Button title="dispatchEventWithResponseCallback()" onPress={dispatchEventWithResponseCallback}/>
28+
<Button title="extensionVersion()" onPress={coreExtensionVersion} />
29+
<Button title="updateConfiguration" onPress={updateConfiguration} />
30+
<Button title="setPrivacyStatus(OptIn)" onPress={setPrivacyOptIn} />
31+
<Button title="getPrivacyStatus()" onPress={getPrivacyStatus} />
32+
<Button title="log(...)" onPress={log} />
33+
<Button title="setLogLevel(AEPMobileLogLevel.VERBOSE)" onPress={setLogLevel} />
34+
<Button title="getLogLevel()" onPress={getLogLevel} />
35+
<Button title="setPushIdentifier()" onPress={setPushIdentifier} />
36+
<Button title="setAdvertisingIdentifier()" onPress={setAdvertisingIdentifier} />
37+
<Button title="getSdkIdentities()" onPress={getSdkIdentities} />
38+
<Button title="collectPii()" onPress={collectPii} />
39+
<Button title="trackAction()" onPress={trackAction} />
40+
<Button title="trackState()" onPress={trackState} />
41+
<Button title="dispatchEvent()" onPress={dispatchEvent} />
42+
<Button title="dispatchEventWithResponseCallback()" onPress={dispatchEventWithResponseCallback} />
43+
<Button title="resetIdentities()" onPress={resetIdentities} />
4344
<Text style={styles.welcome}>Lifecycle</Text>
44-
<Button title="AEPLifecycle::extensionVersion()" onPress={lifecycleExtensionVersion}/>
45+
<Button title="AEPLifecycle::extensionVersion()" onPress={lifecycleExtensionVersion} />
4546
<Text style={styles.welcome}>Signal</Text>
46-
<Button title="AEPSignal::extensionVersion()" onPress={signalExtensionVersion}/>
47-
</ScrollView>
48-
</View>
47+
<Button title="AEPSignal::extensionVersion()" onPress={signalExtensionVersion} />
48+
</ScrollView>
49+
</View>
4950
)
5051
}
5152

52-
function trackAction(){
53-
AEPCore.trackAction("action name", {"key": "value"});
53+
function trackAction() {
54+
AEPCore.trackAction("action name", { "key": "value" });
5455
}
5556

56-
function trackState(){
57-
AEPCore.trackState("state name", {"key": "value"});
57+
function trackState() {
58+
AEPCore.trackState("state name", { "key": "value" });
5859
}
5960

60-
function setPushIdentifier(){
61+
function setPushIdentifier() {
6162
AEPCore.setPushIdentifier("xxx");
6263
}
6364

6465
function collectPii() {
65-
AEPCore.collectPii({"myPii": "data"});
66+
AEPCore.collectPii({ "myPii": "data" });
6667
}
6768

6869
function dispatchEvent() {
69-
var event = new AEPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
70+
var event = new AEPExtensionEvent("eventName", "eventType", "eventSource", { "testDataKey": "testDataValue" });
7071
AEPCore.dispatchEvent(event);
7172
}
7273

7374
function dispatchEventWithResponseCallback() {
74-
var event = new AEPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
75+
var event = new AEPExtensionEvent("eventName", "eventType", "eventSource", { "testDataKey": "testDataValue" });
7576
AEPCore.dispatchEventWithResponseCallback(event).then(responseEvent => console.log("AdobeExperienceSDK: responseEvent = " + responseEvent));
7677
}
7778

@@ -81,8 +82,8 @@ function setAdvertisingIdentifier() {
8182
function getSdkIdentities() {
8283
AEPCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));
8384
}
84-
function updateConfiguration(){
85-
AEPCore.updateConfiguration({"global.privacy":"optedout"});
85+
function updateConfiguration() {
86+
AEPCore.updateConfiguration({ "global.privacy": "optedout" });
8687
}
8788

8889
function getLogLevel() {
@@ -116,6 +117,11 @@ function setPrivacyOptIn() {
116117
function getPrivacyStatus() {
117118
AEPCore.getPrivacyStatus().then(status => console.log("AdobeExperienceSDK: Privacy Status = " + status));
118119
}
120+
119121
function log() {
120122
AEPCore.log(AEPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");
123+
}
124+
125+
function resetIdentities() {
126+
AEPCore.resetIdentities();
121127
}

apps/AEPSampleApp/ios/Podfile.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ PODS:
4848
- RCTAEPAssurance (3.0.0-alpha.0):
4949
- AEPAssurance (~> 3.0)
5050
- React
51-
- RCTAEPCore (1.0.0-alpha.1):
51+
- RCTAEPCore (1.0.0-alpha.2):
5252
- AEPCore (~> 3.0)
5353
- AEPIdentity (~> 3.0)
5454
- AEPLifecycle (~> 3.0)
5555
- AEPSignal (~> 3.0)
5656
- React
57-
- RCTAEPEdge (1.0.0-alpha.1):
57+
- RCTAEPEdge (1.0.0-alpha.2):
5858
- AEPEdge (~> 1.0)
5959
- React
6060
- RCTAEPEdgeIdentity (1.0.0-alpha.2):
6161
- AEPEdgeIdentity (~> 1.0)
6262
- React
63-
- RCTAEPMessaging (1.0.0-alpha.1):
63+
- RCTAEPMessaging (1.0.0-alpha.2):
6464
- AEPMessaging (~> 1.0)
6565
- React
66-
- RCTAEPUserProfile (1.0.0-alpha.2):
66+
- RCTAEPUserProfile (1.0.0-alpha.3):
6767
- AEPUserProfile (~> 3.0)
6868
- React
6969
- RCTRequired (0.64.2)
@@ -250,7 +250,7 @@ PODS:
250250
- React-jsi (= 0.64.2)
251251
- React-perflogger (= 0.64.2)
252252
- React-jsinspector (0.64.2)
253-
- react-native-safe-area-context (3.3.0):
253+
- react-native-safe-area-context (3.3.2):
254254
- React-Core
255255
- React-perflogger (0.64.2)
256256
- React-RCTActionSheet (0.64.2):
@@ -320,7 +320,7 @@ PODS:
320320
- React
321321
- RNGestureHandler (1.10.3):
322322
- React-Core
323-
- RNReanimated (2.2.0):
323+
- RNReanimated (2.2.2):
324324
- DoubleConversion
325325
- FBLazyVector
326326
- FBReactNativeSpec
@@ -349,7 +349,7 @@ PODS:
349349
- React-RCTVibration
350350
- ReactCommon/turbomodule/core
351351
- Yoga
352-
- RNScreens (3.6.0):
352+
- RNScreens (3.8.0):
353353
- React-Core
354354
- React-RCTImage
355355
- Yoga (1.14.0)
@@ -507,15 +507,15 @@ SPEC CHECKSUMS:
507507
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
508508
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
509509
FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b
510-
FBReactNativeSpec: 5ca7548715da0ca374801e008d75e1eb871b5836
510+
FBReactNativeSpec: cdd6f1f8ca74a9d33e4a3727af16caa19a9fae91
511511
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
512512
RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c
513513
RCTAEPAssurance: 419c28c8d04829cdf40b802ed5227e7ab039c329
514-
RCTAEPCore: 6dfa0402c077510e4b08c1782350640d53cb83e4
515-
RCTAEPEdge: 1ff651b4e56d6200eaa8dde8ef049ba39a1eccaf
514+
RCTAEPCore: e89ca896f56ef03218b8e93a16923c4732650947
515+
RCTAEPEdge: 323ae50007fec0771b1a6e6e0ddc3a309f0408f3
516516
RCTAEPEdgeIdentity: 245c00a7c8e7b27a902b7839238aa3726366f732
517-
RCTAEPMessaging: bda1f87bc2740eb335ea911e73b8377049053e5e
518-
RCTAEPUserProfile: 53b3cc558dccf3d0ec367fc27493087bde9e834d
517+
RCTAEPMessaging: 27172e5d88894eacf1f57fd3b44f9e9ea504dbd0
518+
RCTAEPUserProfile: 4614a2995a168193d76df61c458e1ad25b282014
519519
RCTRequired: 6d3e854f0e7260a648badd0d44fc364bc9da9728
520520
RCTTypeSafety: c1f31d19349c6b53085766359caac425926fafaa
521521
React: bda6b6d7ae912de97d7a61aa5c160db24aa2ad69
@@ -526,7 +526,7 @@ SPEC CHECKSUMS:
526526
React-jsi: 67747b9722f6dab2ffe15b011bcf6b3f2c3f1427
527527
React-jsiexecutor: 80c46bd381fd06e418e0d4f53672dc1d1945c4c3
528528
React-jsinspector: cc614ec18a9ca96fd275100c16d74d62ee11f0ae
529-
react-native-safe-area-context: 61c8c484a3a9e7d1fda19f7b1794b35bbfd2262a
529+
react-native-safe-area-context: 584dc04881deb49474363f3be89e4ca0e854c057
530530
React-perflogger: 25373e382fed75ce768a443822f07098a15ab737
531531
React-RCTActionSheet: af7796ba49ffe4ca92e7277a5d992d37203f7da5
532532
React-RCTAnimation: 6a2e76ab50c6f25b428d81b76a5a45351c4d77aa
@@ -541,8 +541,8 @@ SPEC CHECKSUMS:
541541
ReactCommon: 149906e01aa51142707a10665185db879898e966
542542
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
543543
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
544-
RNReanimated: 9c13c86454bfd54dab7505c1a054470bfecd2563
545-
RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e
544+
RNReanimated: 241c586663f44f19a53883c63375fdd041253960
545+
RNScreens: 6e1ea5787989f92b0671049b808aef64fa1ef98c
546546
Yoga: 575c581c63e0d35c9a83f4b46d01d63abc1100ac
547547

548548
PODFILE CHECKSUM: 2a644d6b375e7638e06413c828ae75a91d8f8598

apps/AEPSampleApp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "eslint ."
1212
},
1313
"dependencies": {
14-
"@adobe/react-native-aepcore": "^1.0.0-alpha.1",
14+
"@adobe/react-native-aepcore": "^1.0.0-alpha.2",
1515
"@adobe/react-native-aepuserprofile": "^1.0.0-alpha.3",
1616
"@adobe/react-native-aepedge": "^1.0.0-alpha.2",
1717
"@adobe/react-native-aepedgeidentity": "^1.0.0-alpha.2",

packages/core/__tests__/AEPCoreTests.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,10 @@ describe('AEPCore', () => {
158158
expect(spy).toHaveBeenCalledWith(appGroup);
159159
});
160160

161+
it('resetIdentities is called', async () => {
162+
const spy = jest.spyOn(NativeModules.AEPCore, 'resetIdentities');
163+
await AEPCore.resetIdentities();
164+
expect(spy).toHaveBeenCalled();
165+
});
166+
161167
});

packages/core/android/src/main/java/com/adobe/marketing/mobile/reactnative/RCTAEPCoreModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public void downloadRules() {
214214
MobileCore.log(LoggingMode.DEBUG, getName(), "downloadRules() cannot be invoked on Android");
215215
}
216216

217+
@ReactMethod
218+
public void resetIdentities() {
219+
MobileCore.resetIdentities();
220+
}
221+
217222
// Helper method/s
218223
private void handleError(Promise promise, ExtensionError error) {
219224
if (error == null || promise == null) {

packages/core/ios/src/Core/RCTAEPCore.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ - (NSData *)dataFromHexString:(NSString *)string {
160160
[AEPLog debugWithLabel:EXTENSION_NAME message:@"setSmallIconResourceID is not suppported on iOS"];
161161
}
162162

163+
164+
RCT_EXPORT_METHOD(resetIdentities) {
165+
[AEPMobileCore resetIdentities];
166+
}
167+
163168
#pragma mark - Helper methods
164169

165170
- (void) handleError:(NSError *) error rejecter:(RCTPromiseRejectBlock) reject {

packages/core/js/AEPCore.js

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ governing permissions and limitations under the License.
1717

1818
const RCTAEPCore = require('react-native').NativeModules.AEPCore;
1919

20-
import type {AEPExtensionEvent} from './models/AEPExtensionEvent';
20+
import type { AEPExtensionEvent } from './models/AEPExtensionEvent';
2121

2222
module.exports = {
2323

@@ -90,14 +90,14 @@ module.exports = {
9090
},
9191

9292
/**
93-
* Sends a log message of the given {@code AEPMobileLogLevel}. If the specified {@code mode} is
94-
* more verbose than the current {@link AEPMobileLogLevel} set from {@link #setLogLevel(AEPMobileLogLevel)}
95-
* then the message is not printed.
96-
*
97-
* @param mode the {@link AEPMobileLogLevel} used to print the message
98-
* @param tag used to identify the source of the log message
99-
* @param message the message to log
100-
*/
93+
* Sends a log message of the given {@code AEPMobileLogLevel}. If the specified {@code mode} is
94+
* more verbose than the current {@link AEPMobileLogLevel} set from {@link #setLogLevel(AEPMobileLogLevel)}
95+
* then the message is not printed.
96+
*
97+
* @param mode the {@link AEPMobileLogLevel} used to print the message
98+
* @param tag used to identify the source of the log message
99+
* @param message the message to log
100+
*/
101101
log(logLevel: string, tag: string, message: string) {
102102
RCTAEPCore.log(logLevel, tag, message);
103103
},
@@ -141,32 +141,32 @@ module.exports = {
141141
},
142142

143143
/**
144-
* This method will be used when the provided {@code AEPExtensionEvent} is used as a trigger and a response event
145-
* is expected in return. The returned event needs to be sent using
146-
* {@link #dispatchResponseEvent(Event, Event, ExtensionErrorCallback)}.
147-
* <p>
148-
*
149-
* @param event required parameter, {@link AEPExtensionEvent} instance to be dispatched, used as a trigger
150-
* @param responseCallback required parameters, {@link Promise} to be called with the response event received
151-
*
152-
* @see AEPCore#dispatchResponseEvent(Event, Event, ExtensionErrorCallback)
144+
* This method will be used when the provided {@code AEPExtensionEvent} is used as a trigger and a response event
145+
* is expected in return. The returned event needs to be sent using
146+
* {@link #dispatchResponseEvent(Event, Event, ExtensionErrorCallback)}.
147+
* <p>
148+
*
149+
* @param event required parameter, {@link AEPExtensionEvent} instance to be dispatched, used as a trigger
150+
* @param responseCallback required parameters, {@link Promise} to be called with the response event received
151+
*
152+
* @see AEPCore#dispatchResponseEvent(Event, Event, ExtensionErrorCallback)
153153
*/
154154
dispatchEventWithResponseCallback(event: AEPExtensionEvent): Promise<AEPExtensionEvent> {
155155
return RCTAEPCore.dispatchEventWithResponseCallback(event);
156156
},
157157

158158
/**
159159
* Android Only
160-
* Dispatches a response event for a paired event that was sent to {@code dispatchEventWithResponseCallback}
161-
* and received by an extension listener {@code hear} method.
162-
*
163-
* @param responseEvent required parameter, {@link AEPExtensionEvent} instance to be dispatched as a response for the
164-
* event sent using {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
165-
* @param requestEvent required parameter, the event sent using
166-
* {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
167-
* @return {@code boolean} indicating if the the event dispatching operation succeeded
168-
*
169-
* @see AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)
160+
* Dispatches a response event for a paired event that was sent to {@code dispatchEventWithResponseCallback}
161+
* and received by an extension listener {@code hear} method.
162+
*
163+
* @param responseEvent required parameter, {@link AEPExtensionEvent} instance to be dispatched as a response for the
164+
* event sent using {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
165+
* @param requestEvent required parameter, the event sent using
166+
* {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
167+
* @return {@code boolean} indicating if the the event dispatching operation succeeded
168+
*
169+
* @see AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)
170170
*/
171171
dispatchResponseEvent(responseEvent: AEPExtensionEvent, requestEvent: AEPExtensionEvent): Promise<boolean> {
172172
return RCTAEPCore.dispatchResponseEvent(responseEvent, requestEvent);
@@ -214,7 +214,7 @@ module.exports = {
214214
*
215215
* @param {String?} advertisingIdentifier the advertising idenifier string.
216216
*/
217-
setAdvertisingIdentifier(advertisingIdentifier?: String) {
217+
setAdvertisingIdentifier(advertisingIdentifier?: String) {
218218
RCTAEPCore.setAdvertisingIdentifier(advertisingIdentifier);
219219
},
220220

@@ -240,17 +240,17 @@ module.exports = {
240240
},
241241

242242
/**
243-
* Sets the resource Id for small icon.
244-
* @param resourceID the resource Id of the icon
245-
*/
243+
* Sets the resource Id for small icon.
244+
* @param resourceID the resource Id of the icon
245+
*/
246246
setSmallIconResourceID(resourceID: number) {
247247
RCTAEPCore.setSmallIconResourceID(resourceID);
248248
},
249249

250250
/**
251-
* Sets the resource Id for large icon.
252-
* @param resourceID the resource Id of the icon
253-
*/
251+
* Sets the resource Id for large icon.
252+
* @param resourceID the resource Id of the icon
253+
*/
254254
setLargeIconResourceID(resourceID: number) {
255255
RCTAEPCore.setLargeIconResourceID(resourceID);
256256
},
@@ -266,4 +266,13 @@ module.exports = {
266266
RCTAEPCore.setAppGroup(appGroup);
267267
},
268268

269+
/**
270+
*
271+
* @brief This method requests that each extension resets the identities it owns. Each extension responds to this request uniquely.
272+
*
273+
*/
274+
resetIdentities() {
275+
RCTAEPCore.resetIdentities();
276+
},
277+
269278
};

packages/core/js/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class AEPCore{
3131
static setSmallIconResourceID(resourceID: number);
3232
static setLargeIconResourceID(resourceID: number);
3333
static setAppGroup(appGroup?: string);
34+
static resetIdentities();
3435
}
3536
export class AEPLifecycle{
3637
static extensionVersion(): Promise<string>;

0 commit comments

Comments
 (0)