Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update react native sdk #10

Merged
merged 3 commits into from
Dec 23, 2021
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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.google.code.gson:gson:2.8.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'one.credify.sdk:android-sdk:v0.1.7'
implementation 'one.credify.sdk:android-sdk:v0.1.9-SN1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ServicexSdkRnModule(reactContext: ReactApplicationContext) : ReactContextB

override fun onError(throwable: CredifyError) {
Log.d("CredifySDK", "Error: ${throwable.throwable}")
promise.reject(throwable.throwable?.message);
promise.reject(throwable.throwable);
}
}
)
Expand All @@ -89,7 +89,7 @@ class ServicexSdkRnModule(reactContext: ReactApplicationContext) : ReactContextB
@ReactMethod
fun setUserProfile(userDict: ReadableMap) {
mUserProfile = UserProfile(
id = userDict.getInt("id")!!.toString(),
id = userDict.getInt("id").toString(),
name = UserName(
firstName = userDict.getString("first_name")!!,
lastName = userDict.getString("last_name")!!,
Expand Down Expand Up @@ -143,8 +143,8 @@ class ServicexSdkRnModule(reactContext: ReactApplicationContext) : ReactContextB
}
},
offerPageCallback = object : CredifySDK.OfferPageCallback {
override fun onClose() {
Log.d("CredifySDK", "Offer page is close")
override fun onClose(status: RedemptionResult) {
Log.d("CredifySDK", "Redemtion Status is " + status.name)
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ android {
applicationId "com.example.servicexsdkrn"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionCode 3
versionName "1.0"
}
splits {
Expand Down
38 changes: 19 additions & 19 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- boost-for-react-native (1.63.0)
- CredifyCryptoSwift (1.1.14)
- CredifyCryptoSwift (1.1.16)
- DoubleConversion (1.1.6)
- FBLazyVector (0.63.4)
- FBReactNativeSpec (0.63.4):
Expand All @@ -21,8 +21,8 @@ PODS:
- glog
- glog (0.3.5)
- KeychainAccess (4.2.2)
- Kingfisher (6.3.1)
- lottie-ios (3.2.3)
- Kingfisher (7.1.2)
- lottie-ios (3.3.0)
- RCTRequired (0.63.4)
- RCTTypeSafety (0.63.4):
- FBLazyVector (= 0.63.4)
Expand Down Expand Up @@ -249,20 +249,20 @@ PODS:
- React-Core (= 0.63.4)
- React-cxxreact (= 0.63.4)
- React-jsi (= 0.63.4)
- Realm (10.12.0):
- Realm/Headers (= 10.12.0)
- Realm/Headers (10.12.0)
- RealmSwift (10.12.0):
- Realm (= 10.12.0)
- serviceX (0.3.0):
- Realm (10.20.1):
- Realm/Headers (= 10.20.1)
- Realm/Headers (10.20.1)
- RealmSwift (10.20.1):
- Realm (= 10.20.1)
- serviceX (0.7.0):
- CredifyCryptoSwift
- KeychainAccess
- Kingfisher
- lottie-ios
- RealmSwift
- servicex-rn (0.2.0):
- servicex-rn (0.3.1):
- React-Core
- serviceX
- serviceX (~> 0.7.0)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -365,15 +365,15 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
CredifyCryptoSwift: 3f79ab1a27467d9cd7cacc07361efa2aeec03b06
CredifyCryptoSwift: 8c1d7e9c477bcadd2f457883b32d2c80a187c238
DoubleConversion: cde416483dac037923206447da6e1454df403714
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
Folly: b73c3869541e86821df3c387eb0af5f65addfab4
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51
Kingfisher: 016c8b653a35add51dd34a3aba36b580041acc74
lottie-ios: c058aeafa76daa4cf64d773554bccc8385d0150e
Kingfisher: 44ed6a8504763f27bab46163adfac83f5deb240c
lottie-ios: 6ac74dcc09904798f59b18cb3075c089d76be9ae
RCTRequired: 082f10cd3f905d6c124597fd1c14f6f2655ff65e
RCTTypeSafety: 8c9c544ecbf20337d069e4ae7fd9a377aadf504b
React: b0a957a2c44da4113b0c4c9853d8387f8e64e615
Expand All @@ -394,12 +394,12 @@ SPEC CHECKSUMS:
React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
Realm: 32488213acb44660539c619d620cec1bac046166
RealmSwift: 0abdca6231d5ff8a4f84cef9c1121ef95a483faf
serviceX: 813dc0ec9bb386afb3b94db144bc19bfefb5c82a
servicex-rn: e755a22defde651eff53951baab9e8ed9821132f
Realm: fac5ecd031fcb81171627b74944c885662d4b266
RealmSwift: 9b02d25acb46a14756bde9893abb99e2e3675923
serviceX: 4550aa3018d35abb30a168776359c1bc9ec95fe3
servicex-rn: 07e359ad97d1b74fba2ad8d5bd043fc809680ba8
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6

PODFILE CHECKSUM: a5b218bbdb51a4d4184f314c8b11972b0d7cb4ec

COCOAPODS: 1.10.1
COCOAPODS: 1.10.2
6 changes: 3 additions & 3 deletions example/ios/ServicexSdkRnExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh index.tsx\n";
};
E409D9B1AFDA6E6AABE98E3A /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -328,7 +328,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 34C29C245L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = ServicexSdkRnExample/Info.plist;
Expand Down Expand Up @@ -356,7 +356,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 34C29C245L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = ServicexSdkRnExample/Info.plist;
Expand Down
1 change: 0 additions & 1 deletion ios/ServicexSdkRn.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ @interface RCT_EXTERN_MODULE(ServicexSdkRn, NSObject)
RCT_EXTERN_METHOD(showPassport:(RCTResponseSenderBlock)dismissCB)
RCT_EXTERN_METHOD(setPushClaimRequestStatus:(BOOL)isSuccess)
RCT_EXTERN_METHOD(appDidBecomeActive:(UIApplication *)application)
//RCT_EXTERN_METHOD(showReferral)

@end

33 changes: 13 additions & 20 deletions ios/ServicexSdkRn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ class ServicexSdkRn: NSObject {

@objc(initialize:environment:marketName:packageVersion:)
func initialize(apiKey:String, environment: String, marketName: String, packageVersion: String) -> Void {
let envDict = ["DEV": EnvironmentType.DEV, "PRODUCTION": EnvironmentType.PRODUCTION,"SANDBOX": EnvironmentType.SANDBOX,"SIT": EnvironmentType.SIT,"UAT": EnvironmentType.UAT]
let envDict = ["DEV": CCEnvironmentType.DEV, "PRODUCTION": .PRODUCTION,"SANDBOX": .SANDBOX,"SIT": .SIT,"UAT": .UAT]

let config = CredifyServiceXConfiguration(apiKey: apiKey,
environment: envDict[environment]!, appName: marketName)
CredifyServiceX.shared.config(with: config)
CredifyServiceX.shared.applicationDidBecomeActive(UIApplication.shared)
CredifyServiceX.shared.setVersion(version: "servicex/rn/android/\(packageVersion)")
let config = serviceXConfig(apiKey: apiKey, env: envDict[environment]!, appName: marketName)
CredifyServiceX.configure(config)
CredifyServiceX.updateUserAgent("servicex/rn/ios/\(packageVersion)")
CredifyServiceX.applicationDidBecomeActive(UIApplication.shared)
}

// In case we need to trigger it manually in AppDelegate Callback
// In case we need to trigger it manually in AppDelegate Callback
@objc(appDidBecomeActive:)
func appDidBecomeActive(application: UIApplication) -> Void {
CredifyServiceX.shared.applicationDidBecomeActive(application)
CredifyServiceX.applicationDidBecomeActive(application)
}

func parseUserProfile(value:NSDictionary) -> CCPlatformUserModel? {
Expand Down Expand Up @@ -63,7 +62,7 @@ class ServicexSdkRn: NSObject {
}

print(_productTypes)
ServiceXService.shared.offerService.getOffers(phoneNumber: user?.phoneNumber,
CredifyServiceX.offer.getOffers(phoneNumber: user?.phoneNumber,
countryCode: user?.countryCode,
localId: user!.id,
credifyId: user?.credifyId, productTypes:_productTypes) { [weak self] result in
Expand All @@ -89,7 +88,7 @@ class ServicexSdkRn: NSObject {

@objc(clearCache)
func clearCache(){
ServiceXService.shared.sessionService.resetSession()
CredifyServiceX.session.resetSession()
}

@objc(setPushClaimRequestStatus:)
Expand All @@ -106,28 +105,22 @@ class ServicexSdkRn: NSObject {
item.id == offerId
})
DispatchQueue.main.async {
ServiceXService.shared.offerService.presentModally(from: UIApplication.shared.keyWindow!.rootViewController!, offer: offer!, userProfile: user!){ credifyId, result in
CredifyServiceX.offer.presentModally(from: UIApplication.shared.keyWindow!.rootViewController!, offer: offer!, userProfile: user!){ credifyId, result in
// Demo Market call push claim token
pushClaimCB([user?.id, credifyId])
self.pushClaimResponseCallback = result
}

ServiceXService.shared.offerService.redemptionResult = { result in
} completionHandler: { result in
print("**** Result is ****")
print(result)
}
}
}

// @objc(showReferral)
// func showReferral(){
//
// }

@objc(showPassport:)
func showPassport(dismissCB:@escaping(RCTResponseSenderBlock)){
let user = self.parseUserProfile(value: userInput!)
DispatchQueue.main.async {
ServiceXService.shared.offerService.showPassport(from: UIApplication.shared.keyWindow!.rootViewController!, userProfile: user!) {
CredifyServiceX.offer.showPassport(from: UIApplication.shared.keyWindow!.rootViewController!, userProfile: user!) {
dismissCB([])
}
}
Expand Down
2 changes: 1 addition & 1 deletion servicex-rn.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "React-Core"
s.dependency "serviceX" , '~> 0.3.0'
s.dependency "serviceX" , '~> 0.7.0'
end