Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 38 additions & 32 deletions apps/AEPSampleApp/extensions/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,64 +14,65 @@ governing permissions and limitations under the License.
*/

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

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

return (
<View style={styles.container}>
<ScrollView contentContainerStyle={{ marginTop: 75 }}>
<ScrollView contentContainerStyle={{ marginTop: 75 }}>
<Button onPress={() => navigation.goBack()} title="Go to main page" />
<Text style={styles.welcome}>Core</Text>
<Button title="extensionVersion()" onPress={coreExtensionVersion}/>
<Button title="updateConfiguration" onPress={updateConfiguration}/>
<Button title="setPrivacyStatus(OptIn)" onPress={setPrivacyOptIn}/>
<Button title="getPrivacyStatus()" onPress={getPrivacyStatus}/>
<Button title="log(...)" onPress={log}/>
<Button title="setLogLevel(AEPMobileLogLevel.VERBOSE)" onPress={setLogLevel}/>
<Button title="getLogLevel()" onPress={getLogLevel}/>
<Button title="setPushIdentifier()" onPress={setPushIdentifier}/>
<Button title="setAdvertisingIdentifier()" onPress={setAdvertisingIdentifier}/>
<Button title="getSdkIdentities()" onPress={getSdkIdentities}/>
<Button title="collectPii()" onPress={collectPii}/>
<Button title="trackAction()" onPress={trackAction}/>
<Button title="trackState()" onPress={trackState}/>
<Button title="dispatchEvent()" onPress={dispatchEvent}/>
<Button title="dispatchEventWithResponseCallback()" onPress={dispatchEventWithResponseCallback}/>
<Button title="extensionVersion()" onPress={coreExtensionVersion} />
<Button title="updateConfiguration" onPress={updateConfiguration} />
<Button title="setPrivacyStatus(OptIn)" onPress={setPrivacyOptIn} />
<Button title="getPrivacyStatus()" onPress={getPrivacyStatus} />
<Button title="log(...)" onPress={log} />
<Button title="setLogLevel(AEPMobileLogLevel.VERBOSE)" onPress={setLogLevel} />
<Button title="getLogLevel()" onPress={getLogLevel} />
<Button title="setPushIdentifier()" onPress={setPushIdentifier} />
<Button title="setAdvertisingIdentifier()" onPress={setAdvertisingIdentifier} />
<Button title="getSdkIdentities()" onPress={getSdkIdentities} />
<Button title="collectPii()" onPress={collectPii} />
<Button title="trackAction()" onPress={trackAction} />
<Button title="trackState()" onPress={trackState} />
<Button title="dispatchEvent()" onPress={dispatchEvent} />
<Button title="dispatchEventWithResponseCallback()" onPress={dispatchEventWithResponseCallback} />
<Button title="resetIdentities()" onPress={resetIdentities} />
<Text style={styles.welcome}>Lifecycle</Text>
<Button title="AEPLifecycle::extensionVersion()" onPress={lifecycleExtensionVersion}/>
<Button title="AEPLifecycle::extensionVersion()" onPress={lifecycleExtensionVersion} />
<Text style={styles.welcome}>Signal</Text>
<Button title="AEPSignal::extensionVersion()" onPress={signalExtensionVersion}/>
</ScrollView>
</View>
<Button title="AEPSignal::extensionVersion()" onPress={signalExtensionVersion} />
</ScrollView>
</View>
)
}

function trackAction(){
AEPCore.trackAction("action name", {"key": "value"});
function trackAction() {
AEPCore.trackAction("action name", { "key": "value" });
}

function trackState(){
AEPCore.trackState("state name", {"key": "value"});
function trackState() {
AEPCore.trackState("state name", { "key": "value" });
}

function setPushIdentifier(){
function setPushIdentifier() {
AEPCore.setPushIdentifier("xxx");
}

function collectPii() {
AEPCore.collectPii({"myPii": "data"});
AEPCore.collectPii({ "myPii": "data" });
}

function dispatchEvent() {
var event = new AEPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
var event = new AEPExtensionEvent("eventName", "eventType", "eventSource", { "testDataKey": "testDataValue" });
AEPCore.dispatchEvent(event);
}

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

Expand All @@ -81,8 +82,8 @@ function setAdvertisingIdentifier() {
function getSdkIdentities() {
AEPCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));
}
function updateConfiguration(){
AEPCore.updateConfiguration({"global.privacy":"optedout"});
function updateConfiguration() {
AEPCore.updateConfiguration({ "global.privacy": "optedout" });
}

function getLogLevel() {
Expand Down Expand Up @@ -116,6 +117,11 @@ function setPrivacyOptIn() {
function getPrivacyStatus() {
AEPCore.getPrivacyStatus().then(status => console.log("AdobeExperienceSDK: Privacy Status = " + status));
}

function log() {
AEPCore.log(AEPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");
}

function resetIdentities() {
AEPCore.resetIdentities();
}
30 changes: 15 additions & 15 deletions apps/AEPSampleApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ PODS:
- RCTAEPAssurance (3.0.0-alpha.0):
- AEPAssurance (~> 3.0)
- React
- RCTAEPCore (1.0.0-alpha.1):
- RCTAEPCore (1.0.0-alpha.2):
- AEPCore (~> 3.0)
- AEPIdentity (~> 3.0)
- AEPLifecycle (~> 3.0)
- AEPSignal (~> 3.0)
- React
- RCTAEPEdge (1.0.0-alpha.1):
- RCTAEPEdge (1.0.0-alpha.2):
- AEPEdge (~> 1.0)
- React
- RCTAEPEdgeIdentity (1.0.0-alpha.2):
- AEPEdgeIdentity (~> 1.0)
- React
- RCTAEPMessaging (1.0.0-alpha.1):
- RCTAEPMessaging (1.0.0-alpha.2):
- AEPMessaging (~> 1.0)
- React
- RCTAEPUserProfile (1.0.0-alpha.2):
- RCTAEPUserProfile (1.0.0-alpha.3):
- AEPUserProfile (~> 3.0)
- React
- RCTRequired (0.64.2)
Expand Down Expand Up @@ -250,7 +250,7 @@ PODS:
- React-jsi (= 0.64.2)
- React-perflogger (= 0.64.2)
- React-jsinspector (0.64.2)
- react-native-safe-area-context (3.3.0):
- react-native-safe-area-context (3.3.2):
- React-Core
- React-perflogger (0.64.2)
- React-RCTActionSheet (0.64.2):
Expand Down Expand Up @@ -320,7 +320,7 @@ PODS:
- React
- RNGestureHandler (1.10.3):
- React-Core
- RNReanimated (2.2.0):
- RNReanimated (2.2.2):
- DoubleConversion
- FBLazyVector
- FBReactNativeSpec
Expand Down Expand Up @@ -349,7 +349,7 @@ PODS:
- React-RCTVibration
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.6.0):
- RNScreens (3.8.0):
- React-Core
- React-RCTImage
- Yoga (1.14.0)
Expand Down Expand Up @@ -507,15 +507,15 @@ SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b
FBReactNativeSpec: 5ca7548715da0ca374801e008d75e1eb871b5836
FBReactNativeSpec: cdd6f1f8ca74a9d33e4a3727af16caa19a9fae91
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c
RCTAEPAssurance: 419c28c8d04829cdf40b802ed5227e7ab039c329
RCTAEPCore: 6dfa0402c077510e4b08c1782350640d53cb83e4
RCTAEPEdge: 1ff651b4e56d6200eaa8dde8ef049ba39a1eccaf
RCTAEPCore: e89ca896f56ef03218b8e93a16923c4732650947
RCTAEPEdge: 323ae50007fec0771b1a6e6e0ddc3a309f0408f3
RCTAEPEdgeIdentity: 245c00a7c8e7b27a902b7839238aa3726366f732
RCTAEPMessaging: bda1f87bc2740eb335ea911e73b8377049053e5e
RCTAEPUserProfile: 53b3cc558dccf3d0ec367fc27493087bde9e834d
RCTAEPMessaging: 27172e5d88894eacf1f57fd3b44f9e9ea504dbd0
RCTAEPUserProfile: 4614a2995a168193d76df61c458e1ad25b282014
RCTRequired: 6d3e854f0e7260a648badd0d44fc364bc9da9728
RCTTypeSafety: c1f31d19349c6b53085766359caac425926fafaa
React: bda6b6d7ae912de97d7a61aa5c160db24aa2ad69
Expand All @@ -526,7 +526,7 @@ SPEC CHECKSUMS:
React-jsi: 67747b9722f6dab2ffe15b011bcf6b3f2c3f1427
React-jsiexecutor: 80c46bd381fd06e418e0d4f53672dc1d1945c4c3
React-jsinspector: cc614ec18a9ca96fd275100c16d74d62ee11f0ae
react-native-safe-area-context: 61c8c484a3a9e7d1fda19f7b1794b35bbfd2262a
react-native-safe-area-context: 584dc04881deb49474363f3be89e4ca0e854c057
React-perflogger: 25373e382fed75ce768a443822f07098a15ab737
React-RCTActionSheet: af7796ba49ffe4ca92e7277a5d992d37203f7da5
React-RCTAnimation: 6a2e76ab50c6f25b428d81b76a5a45351c4d77aa
Expand All @@ -541,8 +541,8 @@ SPEC CHECKSUMS:
ReactCommon: 149906e01aa51142707a10665185db879898e966
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNReanimated: 9c13c86454bfd54dab7505c1a054470bfecd2563
RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e
RNReanimated: 241c586663f44f19a53883c63375fdd041253960
RNScreens: 6e1ea5787989f92b0671049b808aef64fa1ef98c
Yoga: 575c581c63e0d35c9a83f4b46d01d63abc1100ac

PODFILE CHECKSUM: 2a644d6b375e7638e06413c828ae75a91d8f8598
Expand Down
2 changes: 1 addition & 1 deletion apps/AEPSampleApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "eslint ."
},
"dependencies": {
"@adobe/react-native-aepcore": "^1.0.0-alpha.1",
"@adobe/react-native-aepcore": "^1.0.0-alpha.2",
"@adobe/react-native-aepuserprofile": "^1.0.0-alpha.3",
"@adobe/react-native-aepedge": "^1.0.0-alpha.2",
"@adobe/react-native-aepedgeidentity": "^1.0.0-alpha.2",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/__tests__/AEPCoreTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,10 @@ describe('AEPCore', () => {
expect(spy).toHaveBeenCalledWith(appGroup);
});

it('resetIdentities is called', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'resetIdentities');
await AEPCore.resetIdentities();
expect(spy).toHaveBeenCalled();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ public void downloadRules() {
MobileCore.log(LoggingMode.DEBUG, getName(), "downloadRules() cannot be invoked on Android");
}

@ReactMethod
public void resetIdentities() {
MobileCore.resetIdentities();
}

// Helper method/s
private void handleError(Promise promise, ExtensionError error) {
if (error == null || promise == null) {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/ios/src/Core/RCTAEPCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ - (NSData *)dataFromHexString:(NSString *)string {
[AEPLog debugWithLabel:EXTENSION_NAME message:@"setSmallIconResourceID is not suppported on iOS"];
}


RCT_EXPORT_METHOD(resetIdentities) {
[AEPMobileCore resetIdentities];
}

#pragma mark - Helper methods

- (void) handleError:(NSError *) error rejecter:(RCTPromiseRejectBlock) reject {
Expand Down
79 changes: 44 additions & 35 deletions packages/core/js/AEPCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ governing permissions and limitations under the License.

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

import type {AEPExtensionEvent} from './models/AEPExtensionEvent';
import type { AEPExtensionEvent } from './models/AEPExtensionEvent';

module.exports = {

Expand Down Expand Up @@ -90,14 +90,14 @@ module.exports = {
},

/**
* Sends a log message of the given {@code AEPMobileLogLevel}. If the specified {@code mode} is
* more verbose than the current {@link AEPMobileLogLevel} set from {@link #setLogLevel(AEPMobileLogLevel)}
* then the message is not printed.
*
* @param mode the {@link AEPMobileLogLevel} used to print the message
* @param tag used to identify the source of the log message
* @param message the message to log
*/
* Sends a log message of the given {@code AEPMobileLogLevel}. If the specified {@code mode} is
* more verbose than the current {@link AEPMobileLogLevel} set from {@link #setLogLevel(AEPMobileLogLevel)}
* then the message is not printed.
*
* @param mode the {@link AEPMobileLogLevel} used to print the message
* @param tag used to identify the source of the log message
* @param message the message to log
*/
log(logLevel: string, tag: string, message: string) {
RCTAEPCore.log(logLevel, tag, message);
},
Expand Down Expand Up @@ -141,32 +141,32 @@ module.exports = {
},

/**
* This method will be used when the provided {@code AEPExtensionEvent} is used as a trigger and a response event
* is expected in return. The returned event needs to be sent using
* {@link #dispatchResponseEvent(Event, Event, ExtensionErrorCallback)}.
* <p>
*
* @param event required parameter, {@link AEPExtensionEvent} instance to be dispatched, used as a trigger
* @param responseCallback required parameters, {@link Promise} to be called with the response event received
*
* @see AEPCore#dispatchResponseEvent(Event, Event, ExtensionErrorCallback)
* This method will be used when the provided {@code AEPExtensionEvent} is used as a trigger and a response event
* is expected in return. The returned event needs to be sent using
* {@link #dispatchResponseEvent(Event, Event, ExtensionErrorCallback)}.
* <p>
*
* @param event required parameter, {@link AEPExtensionEvent} instance to be dispatched, used as a trigger
* @param responseCallback required parameters, {@link Promise} to be called with the response event received
*
* @see AEPCore#dispatchResponseEvent(Event, Event, ExtensionErrorCallback)
*/
dispatchEventWithResponseCallback(event: AEPExtensionEvent): Promise<AEPExtensionEvent> {
return RCTAEPCore.dispatchEventWithResponseCallback(event);
},

/**
* Android Only
* Dispatches a response event for a paired event that was sent to {@code dispatchEventWithResponseCallback}
* and received by an extension listener {@code hear} method.
*
* @param responseEvent required parameter, {@link AEPExtensionEvent} instance to be dispatched as a response for the
* event sent using {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
* @param requestEvent required parameter, the event sent using
* {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
* @return {@code boolean} indicating if the the event dispatching operation succeeded
*
* @see AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)
* Dispatches a response event for a paired event that was sent to {@code dispatchEventWithResponseCallback}
* and received by an extension listener {@code hear} method.
*
* @param responseEvent required parameter, {@link AEPExtensionEvent} instance to be dispatched as a response for the
* event sent using {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
* @param requestEvent required parameter, the event sent using
* {@link AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)}
* @return {@code boolean} indicating if the the event dispatching operation succeeded
*
* @see AEPCore#dispatchEventWithResponseCallback(AEPExtensionEvent)
*/
dispatchResponseEvent(responseEvent: AEPExtensionEvent, requestEvent: AEPExtensionEvent): Promise<boolean> {
return RCTAEPCore.dispatchResponseEvent(responseEvent, requestEvent);
Expand Down Expand Up @@ -214,7 +214,7 @@ module.exports = {
*
* @param {String?} advertisingIdentifier the advertising idenifier string.
*/
setAdvertisingIdentifier(advertisingIdentifier?: String) {
setAdvertisingIdentifier(advertisingIdentifier?: String) {
RCTAEPCore.setAdvertisingIdentifier(advertisingIdentifier);
},

Expand All @@ -240,17 +240,17 @@ module.exports = {
},

/**
* Sets the resource Id for small icon.
* @param resourceID the resource Id of the icon
*/
* Sets the resource Id for small icon.
* @param resourceID the resource Id of the icon
*/
setSmallIconResourceID(resourceID: number) {
RCTAEPCore.setSmallIconResourceID(resourceID);
},

/**
* Sets the resource Id for large icon.
* @param resourceID the resource Id of the icon
*/
* Sets the resource Id for large icon.
* @param resourceID the resource Id of the icon
*/
setLargeIconResourceID(resourceID: number) {
RCTAEPCore.setLargeIconResourceID(resourceID);
},
Expand All @@ -266,4 +266,13 @@ module.exports = {
RCTAEPCore.setAppGroup(appGroup);
},

/**
*
* @brief This method requests that each extension resets the identities it owns. Each extension responds to this request uniquely.
*
*/
resetIdentities() {
RCTAEPCore.resetIdentities();
},

};
1 change: 1 addition & 0 deletions packages/core/js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class AEPCore{
static setSmallIconResourceID(resourceID: number);
static setLargeIconResourceID(resourceID: number);
static setAppGroup(appGroup?: string);
static resetIdentities();
}
export class AEPLifecycle{
static extensionVersion(): Promise<string>;
Expand Down
Loading