Skip to content

Commit

Permalink
Merge pull request #70 from oracle/7.0.0
Browse files Browse the repository at this point in the history
cx sdk 7.0.0
  • Loading branch information
neerhaj authored Oct 14, 2024
2 parents a8e1e00 + 5cce59d commit 5317666
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 81 deletions.
16 changes: 8 additions & 8 deletions PushIOManager/PushIOManager.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Pod::Spec.new do |s|
s.version = "6.56.4"
s.version = "7.0.0"
s.name = "PushIOManager"
s.summary = "Responsys iOS SDK"
s.summary = "CX iOS SDK"
s.documentation_url = ""
s.homepage = "https://github.com/pushio/PushIOManager_iOS"
s.homepage = "https://www.oracle.com/downloads/applications/cx/responsys-mobile-sdk.html"
s.author = "Oracle"
s.license = ""
s.source = { :git => "https://github.com/pushio/PushIOManager_iOS", :tag => s.version.to_s }
s.license = ""
s.source = { :http => "https://www.oracle.com/downloads/applications/cx/responsys-mobile-sdk.html", :tag => s.version.to_s }

s.module_name = "PushIOManager"
s.ios.deployment_target = "10.0"
s.ios.deployment_target = "12.0"
s.requires_arc = true

s.vendored_frameworks = "PushIOManager.xcframework"
s.preserve_paths = "PushIOManager.xcframework"
s.vendored_frameworks = 'framework/CX_Mobile_SDK.xcframework','framework/OracleCXLocationSDK.xcframework'
s.preserve_paths = "framework/CX_Mobile_SDK.xcframework/**/*","framework/OracleCXLocationSDK.xcframework/**/*"

s.libraries = 'sqlite3'
s.frameworks = 'UserNotifications', 'CoreLocation', 'Foundation', 'UIKit'
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This module makes it easy to integrate your React Native based mobile app with t

## Requirements

- React Native >= 0.61.5
- React Native >= 0.73.6
- React Native CLI >= 2.0.1

### For Android
Expand All @@ -59,7 +59,8 @@ Before installing the plugin, you must setup your app to receive push notificati
- [Generate Auth Key](https://docs.oracle.com/en/cloud/saas/marketing/responsys-develop-mobile/ios/auth-key/)
- Log in to the [Responsys Mobile App Developer Console](https://docs.oracle.com/en/cloud/saas/marketing/responsys-develop-mobile/dev-console/login/) and enter your Auth Key and other details for your iOS app.
- Download the `pushio_config.json` file generated from your credentials.
- ***Important:*** Copy `PushIOManager.xcframework` and place it in `YOUR_APP_DIR/ios/framework/` folder **before adding plugin to project**.
- ***Important:*** Copy `CX_Mobile_SDK.xcframework` and place it in `YOUR_APP_DIR/ios/framework/` folder **before adding plugin to project**.
> **_NOTE:_** Copy OracleCXLocationSDK.xcframework to support Location feature in iOS and add related Privacy Location descriptions in Info.plist, refer this for more info [Location Descriptions](https://developer.apple.com/documentation/corelocation/requesting-authorization-to-use-location-services#Provide-descriptions-of-how-you-use-location-services)

## Installation
Expand Down Expand Up @@ -97,7 +98,7 @@ After installing plugin you need to install cocoapods,
- Run `pod install`


***Note:*** This step will fail if `PushIOManager.xcframework` is not available in `YOUR_APP_DIR/ios/framework/` folder **before adding plugin to project with `npm` or `yarn`**. Copy the `PushIOManager.xcframework` to `YOUR_APP_DIR/ios/framework/` and perform `Installation` step again.
***Note:*** This step will fail if `CX_Mobile_SDK.xcframework` is not available in `YOUR_APP_DIR/ios/framework/` folder **before adding plugin to project with `npm` or `yarn`**. Copy the `CX_Mobile_SDK.xcframework` to `YOUR_APP_DIR/ios/framework/` and perform `Installation` step again.Optionally add OracleCXLocationSDK.xcframework to capture location attributes in responsys.


## Integration
Expand Down Expand Up @@ -282,7 +283,7 @@ import PushIOManager from '@oracle/react-native-pushiomanager';
import { Platform } from 'react-native';

if (Platform.OS === 'android') {
PushIOManager.registerApp(true, true, (error, response) => {
PushIOManager.registerAppForPush(true, true, (error, response) => {
});
} else {
Expand Down Expand Up @@ -687,6 +688,18 @@ PushIOManager.trackConversionEvent(event, (error, response) => {

## Upgrades

### 7.0.0

#### For IOS

API for registration has been changed to: registerApp(useLocation, callback)

This allows your app to control when to display the location permission prompt on iOS 12 and later devices.

#### For Android

API for registration has been changed to: registerAppForPush(enablePushNotification, useLocation, callback)

### 6.56.3

#### For Android
Expand Down Expand Up @@ -736,7 +749,9 @@ Due to this change, you will need to perform the following steps one-time only.
```

- Create a `framework` directory inside `YOUR_APP_DIR/ios/` directory.
- Copy the latest PushIOManager.xcframework inside `YOUR_APP_DIR/ios/framework/`
- Copy the latest CX_Mobile_SDK.xcframework inside `YOUR_APP_DIR/ios/framework/`
> **_NOTE:_** Copy `OracleCXLocationSDK.xcframework` to support Location feature in iOS and add releated Privacy Location descriptiions in Info.plist, refer this for more info
[Location Descriptions](https://developer.apple.com/documentation/corelocation/requesting-authorization-to-use-location-services#Provide-descriptions-of-how-you-use-location-services)
- Install the latest plugin `yarn add @oracle/react-native-pushiomanager`


Expand Down
12 changes: 12 additions & 0 deletions android/src/main/java/com/pushio/manager/rn/RCTPIOCommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ static WritableArray writableArrayFromMCMessages(List<PIOMCMessage> messages) {
writableMap.putString("sentTimestamp", getDateAsString(message.getSentTimestamp()));
writableMap.putString("expiryTimestamp", getDateAsString(message.getExpiryTimestamp()));

Map<String,String> data = message.getCustomKeyValue();

if (data != null && !data.isEmpty()) {
WritableMap dataMap = new WritableNativeMap();

for (Map.Entry<String, String> entry : data.entrySet()) {
dataMap.putString(entry.getKey(), entry.getValue());
}

writableMap.putMap("customKeyValuePairs", dataMap);
}

writableMessages.pushMap(writableMap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,7 @@ public void setLogLevel(int logLevel) {
}

@ReactMethod
public void registerApp(boolean useLocation, final Callback callback) {
mPushIOManager.registerPushIOListener(new PushIOListener() {
@Override
public void onPushIOSuccess() {
if (callback != null) {
callback.invoke(null, "success");
}
}

@Override
public void onPushIOError(String errorReason) {
if (callback != null) {
callback.invoke(errorReason, null);
}
}
});
mPushIOManager.registerApp(useLocation);
}

@ReactMethod
public void registerApp(boolean enablePushNotifications, boolean useLocation, final Callback callback) {
public void registerAppForPush(boolean enablePushNotifications, boolean useLocation, final Callback callback) {
mPushIOManager.registerPushIOListener(new PushIOListener() {
@Override
public void onPushIOSuccess() {
Expand Down
8 changes: 4 additions & 4 deletions framework/PushIOManager.podspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Pod::Spec.new do |s|
s.version = "6.56.4"
s.version = "7.0.0"
s.name = "PushIOManager"
s.summary = "Responsys iOS SDK"
s.documentation_url = ""
Expand All @@ -9,11 +9,11 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/pushio/PushIOManager_iOS", :tag => s.version.to_s }

s.module_name = "PushIOManager"
s.ios.deployment_target = "11.0"
s.ios.deployment_target = "12.0"
s.requires_arc = true

s.vendored_frameworks = "PushIOManager.xcframework"
s.preserve_paths = "PushIOManager.xcframework"
s.vendored_frameworks = 'framework/CX_Mobile_SDK.xcframework','framework/OracleCXLocationSDK.xcframework'
s.preserve_paths = "framework/CX_Mobile_SDK.xcframework/**/*","framework/OracleCXLocationSDK.xcframework/**/*"

s.libraries = 'sqlite3'
s.frameworks = 'UserNotifications', 'CoreLocation', 'Foundation', 'UIKit'
Expand Down
8 changes: 4 additions & 4 deletions iOS.Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mkdir ios/framework
cp node_modules/@oracle/react-native-pushiomanager/PushIOManager/PushIOManager.podspec ios/framework/
```

Place the [latest iOS `PushIOManager.xcframework`](https://www.oracle.com/downloads/applications/cx/responsys-mobile-sdk.html) inside `ios/framework`
Place the [latest iOS `CX_Mobile_SDK.xcframework`](https://www.oracle.com/downloads/applications/cx/responsys-mobile-sdk.html) inside `ios/framework`

After above these steps your framework directory should look like this.

Expand All @@ -54,7 +54,7 @@ Sample Podfile after adding PushIOManager dependenct look like this.
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
platform :ios, '12.0'

target 'testapp' do
config = use_native_modules!
Expand Down Expand Up @@ -272,7 +272,7 @@ import PushIOManager from 'react-native-pushiomanager';
});
} else {
PushIOManager.registerForAllRemoteNotificationTypes((error, response) => { //This api will raise iOS push permission alert
PushIOManager.registerApp(false, (error, response) => {
PushIOManager.registerApp(true, (error, response) => {
});
});
}
Expand All @@ -288,7 +288,7 @@ import PushIOManager from 'react-native-pushiomanager';
});
} else {
PushIOManager.registerForAllRemoteNotificationTypes((error, response) => { //This api will raise iOS push permission alert
PushIOManager.registerApp(false, (error, response) => { //Register for iOS. `useLocation` is not supported in iOS.
PushIOManager.registerApp(true, (error, response) => { //Register for iOS. `useLocation` is now supported in 7.0.0.

});
});
Expand Down
43 changes: 19 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,40 +157,36 @@ export default class PushIOManager {
/**
* Registers this app installation with Responsys.
*
* @param {boolean} enablePushNotification Whether to enable push notifications. Passing `true` will show the default system push notification permission dialog prompt.
* (Not available on iOS platform.)
* @param {boolean} useLocation Whether to send location data along with the registration request. Passing `true` will show the default system location permission dialog prompt.
* (User location is not available on iOS platform.)
* @param {callback} callback callback with boolean value TRUE if register event created and stored successfully, FALSE otherwise.
* @see {@tutorial Config}
*/


static registerApp(useLocation, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.registerApp(useLocation, callback);
} else {
RCTPushIOManager.registerApp(callback);
static registerAppForPush(enablePushNotification, useLocation, callback){
if(Platform.OS === 'android'){
RCTPushIOManager.registerAppForPush(enablePushNotification,useLocation,callback);
}else{
RCTPushIOManager.registerApp(useLocation,callback);
}
}


/**
* Registers this app installation with Responsys.
*
* @param {boolean} enablePushNotification Whether to enable push notifications. Passing `true` will show the default system push notification permission dialog prompt.
* (Not available on iOS platform.)
* @param {boolean} useLocation Whether to send location data along with the registration request. Passing `true` will show the default system location permission dialog prompt.
* (User location is not available on iOS platform.)
* @param {callback} callback callback with boolean value TRUE if register event created and stored successfully, FALSE otherwise.
* @see {@tutorial Config}
*/


static registerApp(enablePushNotification, useLocation, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.registerApp(enablePushNotification, useLocation, callback);
} else {
RCTPushIOManager.registerApp(callback);
* Registers this app installation with Responsys
*
* @param {boolean} useLocation Whether to send location data along with the registration request. Passing `true` will show the default system location permission dialog prompt.
* @param {callback} callback callback with boolean value TRUE if register event created and stored successfully, FALSE otherwise.
* @see {@tutorial Config}
*/
static registerApp(useLocation,callback){
if(Platform.OS === 'android'){
console.log("This API is no longer supported. Use PushIOManager.registerAppForPush() for Android.");
}else{
RCTPushIOManager.registerApp(useLocation,callback);
}

}

/**
Expand Down Expand Up @@ -1231,5 +1227,4 @@ export default class PushIOManager {
console.log("API not supported");
}
}

}
2 changes: 1 addition & 1 deletion ios/NSArray+PIOConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import "NSArray+PIOConvert.h"
#import "NSDictionary+PIOConvert.h"
#import <PushIOManager/PushIOManagerAll.h>
#import <CX_Mobile_SDK/PushIOManagerAll.h>

@implementation NSArray (PIOConvert)
- (NSArray *)messageDictionary {
Expand Down
2 changes: 1 addition & 1 deletion ios/NSDictionary+PIOConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


#import <Foundation/Foundation.h>
#import <PushIOManager/PushIOManagerAll.h>
#import <CX_Mobile_SDK/PushIOManagerAll.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
6 changes: 4 additions & 2 deletions ios/PushIoManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -224,7 +224,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand All @@ -240,6 +240,7 @@
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Pushiomanager;
Expand All @@ -256,6 +257,7 @@
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = Pushiomanager;
Expand Down
9 changes: 8 additions & 1 deletion ios/RCTPushIOEventEmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#import "RCTPushIOEventEmitter.h"
#import <Foundation/Foundation.h>
#import <PushIOManager/PushIOManagerAll.h>
#import <CX_Mobile_SDK/PushIOManagerAll.h>

@interface RCTPushIOEventEmitter () {
BOOL openUrlListenerAdded;
Expand All @@ -29,8 +29,15 @@ - (instancetype)init {
return self;
}




RCT_EXPORT_MODULE();

+(BOOL)requiresMainQueueSetup {
return NO;
}

-(void)startObserving {
hasListeners = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resolvedURL:) name:PIORsysWebURLResolvedNotification object:nil];
Expand Down
15 changes: 11 additions & 4 deletions ios/RCTPushIOManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@


#import "RCTPushIOManager.h"
#import <PushIOManager/PushIOManagerAll.h>
#import <CX_Mobile_SDK/PushIOManagerAll.h>
#import <CX_Mobile_SDK/ORACoreConfig.h>
#import <CX_Mobile_SDK/ORACoreConstants.h>
#import "NSDictionary+PIOConvert.h"
#import "NSArray+PIOConvert.h"

Expand All @@ -20,7 +22,12 @@ - (instancetype)init {
self = [super init];

if(self) {

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
ORACoreConfig *config = [[ORACoreConfig alloc] init];
[config setConfigValue:@"rsys" forKey:kORAModules];
});

if([[NSUserDefaults standardUserDefaults] boolForKey:@"PIO_setOpenURLListener"]) {
[[PushIOManager sharedInstance] setDeeplinkDelegate:self];
}
Expand Down Expand Up @@ -65,8 +72,8 @@ +(BOOL)requiresMainQueueSetup {
}];
}

RCT_EXPORT_METHOD(registerApp:(RCTResponseSenderBlock)callback) {
[[PushIOManager sharedInstance] registerApp:nil completionHandler:^(NSError *error, NSString *response) {
RCT_EXPORT_METHOD(registerApp:(BOOL)userLocation completionHandler:(RCTResponseSenderBlock)callback) {
[[PushIOManager sharedInstance] registerApp:nil useLocation:userLocation completionHandler:^(NSError *error, NSString *response) {
callback(@[error.description?: [NSNull null], response ?: @"success"]);
}];
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oracle/react-native-pushiomanager",
"version": "6.56.4",
"version": "7.0.0",
"description": "React Native Module for Responsys Mobile SDK",
"main": "index.js",
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ find_ios_root_path=$(find ../../../ -type d -name ios ! -path "*/node_modules/*"
default_reactnative_root_path="../../../ios"

generate_command_by_path() {
rm -rf ./framework/PushIOManager.xcframework && cp -Rf $( echo $1 )/framework/PushIOManager.xcframework ./framework/ || { echo "\n\n\n Error ==> PushIOManager.xcframework not found. Please copy the PushIOManager.xcframework to YOUR_APP_DIR/ios/framework/ and install package again. Follow README.md Installation instructions.<=== \n\n\n;"
rm -rf ./framework/CX_Mobile_SDK.xcframework && cp -Rf $( echo $1 )/framework/CX_Mobile_SDK.xcframework ./framework/ || { echo "\n\n\n Error ==> CX_Mobile_SDK.xcframework not found. Please copy the CX_Mobile_SDK.xcframework to YOUR_APP_DIR/ios/framework/ and install package again. Follow README.md Installation instructions.<=== \n\n\n;"
exit 1; }
rm -rf ./framework/OracleCXLocationSDK.xcframework && cp -Rf $( echo $1 )/framework/OracleCXLocationSDK.xcframework ./framework/ || { echo "\n\n\n Info ==> OracleCXLocationSDK.xcframework not found. Please copy the OracleCXLocationSDK.xcframework to YOUR_APP_DIR/ios/framework/ and install package again. Follow README.md Installation instructions.<=== \n\n\n;"
exit 0; }
}

# NOTE: to declare variable by bash need to use export CUSTOM_IOS_PATH_PUSHIOMANAGER = path/to/ios/folder
Expand Down
Loading

0 comments on commit 5317666

Please sign in to comment.