diff --git a/RNNearIt.podspec b/RNNearIt.podspec index 1290b42..803f858 100644 --- a/RNNearIt.podspec +++ b/RNNearIt.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '9.0' s.dependency 'React' - s.dependency 'NearITSDK', '~> 2.12.0' - s.dependency 'NearITSDKSwift', '~> 2.12.0' - s.dependency 'NearUIBinding', '~> 2.12.0' + s.dependency 'NearITSDK', '~> 2.12.1' + s.dependency 'NearITSDKSwift', '~> 2.12.1' + s.dependency 'NearUIBinding', '~> 2.12.1' end \ No newline at end of file diff --git a/android/src/main/java/it/near/sdk/reactnative/rnnearitsdk/RNNearItModule.java b/android/src/main/java/it/near/sdk/reactnative/rnnearitsdk/RNNearItModule.java index f8faa4d..97bf15d 100644 --- a/android/src/main/java/it/near/sdk/reactnative/rnnearitsdk/RNNearItModule.java +++ b/android/src/main/java/it/near/sdk/reactnative/rnnearitsdk/RNNearItModule.java @@ -175,12 +175,10 @@ private Map getPermissionsConstants() { // ReactApp Lifecycle methods @Override public void onHostResume() { - // TODO: remove this? -> this.dispatchNotificationQueue(); } @Override public void onHostPause() { - } @Override diff --git a/ios/RNNearIt.m b/ios/RNNearIt.m index 7895076..8481a29 100644 --- a/ios/RNNearIt.m +++ b/ios/RNNearIt.m @@ -234,12 +234,12 @@ - (BOOL)application:(UIApplication* _Nonnull)application didReceiveLocalNotifica RCT_EXPORT_METHOD(addProximityListener) { - [NITManager defaultManager].delegate = self; + NITLogD(TAG, @"addProximityListener::method called but nothing to do on iOS"); } RCT_EXPORT_METHOD(removeProximityListener) { - [NITManager defaultManager].delegate = nil; + NITLogD(TAG, @"removeProximityListener::method called but nothing to do on iOS"); } // MARK: ReactNative listeners management @@ -576,6 +576,8 @@ - (void)loadConfig // Set NearIT framework name [NITManager setFrameworkName:@"react-native"]; + + [NITManager defaultManager].delegate = self; } - (void)sendEventWithContent:(NSDictionary* _Nonnull)content NITEventType:(NSString* _Nonnull)eventType trackingInfo:(NITTrackingInfo* _Nullable)trackingInfo fromUserAction:(BOOL)fromUserAction diff --git a/ios/RNNearItUI.m b/ios/RNNearItUI.m index 17148c3..b0a3fa3 100644 --- a/ios/RNNearItUI.m +++ b/ios/RNNearItUI.m @@ -40,11 +40,11 @@ - (void)dialogClosedWithLocationGranted:(BOOL)locationGranted notificationsGrant } - (void)locationGranted:(BOOL)granted { - // TODO: nothing? + } - (void)notificationsGranted:(BOOL)granted { - // TODO: nothing? + } @@ -84,7 +84,7 @@ - (void)notificationsGranted:(BOOL)granted { // MARK: Coupon related methods -RCT_EXPORT_METHOD(showCoupons: (NSString* _Nullable) title) +RCT_EXPORT_METHOD(showCouponList: (NSString* _Nullable) title) { NITCouponListViewController *couponsVC = [[NITCouponListViewController alloc] init]; if (title != nil) { @@ -96,13 +96,14 @@ - (void)notificationsGranted:(BOOL)granted { // MARK: Content related methods -RCT_EXPORT_METHOD(showContent: (NSDictionary* _Nullable) content) +RCT_EXPORT_METHOD(showContent: (NSDictionary* _Nullable) event) { - if (content != nil) { - NSString* type = [content objectForKey:EVENT_TYPE]; + if (event != nil) { + NSString* type = [event objectForKey:EVENT_TYPE]; + NSDictionary* content = [event objectForKey:EVENT_CONTENT]; if ([type isEqualToString:EVENT_TYPE_CONTENT]) { NITContent* nearContent = [RNNearItUtils unbundleNITContent:content]; - NITTrackingInfo* trackingInfo = [RNNearItUtils unbundleTrackingInfo:[content objectForKey:EVENT_TRACKING_INFO]]; + NITTrackingInfo* trackingInfo = [RNNearItUtils unbundleTrackingInfo:[event objectForKey:EVENT_TRACKING_INFO]]; NITContentViewController *vc = [[NITContentViewController alloc] initWithContent:nearContent trackingInfo:trackingInfo]; [vc show]; } else if ([type isEqualToString:EVENT_TYPE_FEEDBACK]) { @@ -137,7 +138,7 @@ - (NSDictionary*)getPermissionsStatus:(BOOL)notificationGranted return @{ PERMISSIONS_LOCATION_PERMISSION: @(locationGranted), PERMISSIONS_NOTIFICATIONS_PERMISSION: @(notificationGranted), - PERMISSIONS_BLUETOOTH: @NO, + PERMISSIONS_BLUETOOTH: @YES, PERMISSIONS_LOCATION_SERVICES: @(locationServicesOn) }; } diff --git a/ios/RNNearItUtils.h b/ios/RNNearItUtils.h index 5d7febd..d984476 100644 --- a/ios/RNNearItUtils.h +++ b/ios/RNNearItUtils.h @@ -25,7 +25,7 @@ + (NSDictionary* _Nullable)bundleNITContent:(NITContent* _Nonnull)content; + (NITContent* _Nullable)unbundleNITContent:(NSDictionary* _Nonnull)bundledContent; -+ (NSArray* _Nullable)bundleNITHistory:(NSArray* _Nonnull)history; ++ (NSArray* _Nonnull)bundleNITHistory:(NSArray* _Nonnull)history; + (NSDictionary* _Nullable)bundleNITFeedback:(NITFeedback* _Nonnull)feedback; + (NITFeedback* _Nullable)unbundleNITFeedback:(NSDictionary* _Nonnull)bundledFeedback; diff --git a/ios/RNNearItUtils.m b/ios/RNNearItUtils.m index bba73fb..64577db 100644 --- a/ios/RNNearItUtils.m +++ b/ios/RNNearItUtils.m @@ -119,10 +119,31 @@ + (NSDictionary* _Nullable)bundleNITContent:(NITContent * _Nonnull) content + (NITContent* _Nullable)unbundleNITContent:(NSDictionary * _Nonnull)bundledContent { NITContent* content = [[NITContent alloc] init]; - content.title = [bundledContent objectForKey:EVENT_CONTENT_TITLE]; - content.content = [bundledContent objectForKey:EVENT_CONTENT_TEXT]; - content.images = @[[self unbundleNITImage: [bundledContent objectForKey:EVENT_IMAGE]]]; - content.internalLink = [bundledContent objectForKey:EVENT_CONTENT_CTA]; + + NSObject* bundledTitle = [bundledContent objectForKey:EVENT_CONTENT_TITLE]; + if ([bundledTitle isEqual:[NSNull null]]) { + content.title = nil; + } else { + content.title = [bundledContent objectForKey:EVENT_CONTENT_TITLE]; + } + + NSObject* bundledText = [bundledContent objectForKey:EVENT_CONTENT_TEXT]; + if ([bundledText isEqual:[NSNull null]]) { + content.content = nil; + } else { + content.content = [bundledContent objectForKey:EVENT_CONTENT_TEXT]; + } + + NITImage* unbundledImage = [self unbundleNITImage: [bundledContent objectForKey:EVENT_IMAGE]]; + if (unbundledImage) { + content.images = @[unbundledImage]; + } + + NSObject* bundledCTA = [bundledContent objectForKey:EVENT_CONTENT_CTA]; + if (![bundledCTA isEqual:[NSNull null]]) { + content.internalLink = [bundledContent objectForKey:EVENT_CONTENT_CTA]; + } + return content; } @@ -174,6 +195,9 @@ + (NSDictionary* _Nullable)bundleNITImage:(NITImage* _Nonnull)image + (NITImage* _Nullable)unbundleNITImage:(NSDictionary* _Nonnull)bundledImage { + if ([bundledImage isEqual:[NSNull null]]) { + return nil; + } NITImage* image = [[NITImage alloc] init]; if ([bundledImage objectForKey:@"imageData"]) { NSData* imageData = [[NSData alloc] initWithBase64EncodedString:[bundledImage objectForKey:@"imageData"] @@ -195,9 +219,9 @@ + (NSDictionary* _Nullable)bundleNITContentLink:(NITContentLink* _Nonnull)cta // NITHistory -+ (NSArray* _Nullable)bundleNITHistory:(NSArray* _Nonnull)history ++ (NSArray* _Nonnull)bundleNITHistory:(NSArray* _Nonnull)history { - NSMutableArray* bundledHistory; + NSMutableArray* bundledHistory = [NSMutableArray new]; for (id item in history) { [bundledHistory addObject:[self bundleNITHistoryItem:item]]; } diff --git a/package.json b/package.json index cae86d1..2bfa4ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nearit", - "version": "2.12.0-alpha.7", + "version": "2.12.0", "author": "Mattia Panzeri ", "contributors": [ "Federico Boschini " diff --git a/src/NearItManager.js b/src/NearItManager.js index ba93722..78fc942 100644 --- a/src/NearItManager.js +++ b/src/NearItManager.js @@ -221,7 +221,6 @@ export class NearItManager { // Notification history related methods - // TODO: return type static getNotificationHistory (): Promise { return NearItSdk.getNotificationHistory() }