Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/v2.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoboschini committed Jun 27, 2019
2 parents 7d5fc47 + 7950dea commit 4190ee9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 24 deletions.
6 changes: 3 additions & 3 deletions RNNearIt.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,10 @@ private Map<String, Object> getPermissionsConstants() {
// ReactApp Lifecycle methods
@Override
public void onHostResume() {
// TODO: remove this? -> this.dispatchNotificationQueue();
}

@Override
public void onHostPause() {

}

@Override
Expand Down
6 changes: 4 additions & 2 deletions ios/RNNearIt.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions ios/RNNearItUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ - (void)dialogClosedWithLocationGranted:(BOOL)locationGranted notificationsGrant
}

- (void)locationGranted:(BOOL)granted {
// TODO: nothing?

}

- (void)notificationsGranted:(BOOL)granted {
// TODO: nothing?

}


Expand Down Expand Up @@ -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) {
Expand All @@ -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]) {
Expand Down Expand Up @@ -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)
};
}
Expand Down
2 changes: 1 addition & 1 deletion ios/RNNearItUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
+ (NSDictionary* _Nullable)bundleNITContent:(NITContent* _Nonnull)content;
+ (NITContent* _Nullable)unbundleNITContent:(NSDictionary* _Nonnull)bundledContent;

+ (NSArray* _Nullable)bundleNITHistory:(NSArray<NITHistoryItem*>* _Nonnull)history;
+ (NSArray* _Nonnull)bundleNITHistory:(NSArray<NITHistoryItem*>* _Nonnull)history;

+ (NSDictionary* _Nullable)bundleNITFeedback:(NITFeedback* _Nonnull)feedback;
+ (NITFeedback* _Nullable)unbundleNITFeedback:(NSDictionary* _Nonnull)bundledFeedback;
Expand Down
36 changes: 30 additions & 6 deletions ios/RNNearItUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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"]
Expand All @@ -195,9 +219,9 @@ + (NSDictionary* _Nullable)bundleNITContentLink:(NITContentLink* _Nonnull)cta

// NITHistory

+ (NSArray* _Nullable)bundleNITHistory:(NSArray<NITHistoryItem*>* _Nonnull)history
+ (NSArray* _Nonnull)bundleNITHistory:(NSArray<NITHistoryItem*>* _Nonnull)history
{
NSMutableArray* bundledHistory;
NSMutableArray* bundledHistory = [NSMutableArray new];
for (id item in history) {
[bundledHistory addObject:[self bundleNITHistoryItem:item]];
}
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": "react-native-nearit",
"version": "2.12.0-alpha.7",
"version": "2.12.0",
"author": "Mattia Panzeri <[email protected]>",
"contributors": [
"Federico Boschini <[email protected]>"
Expand Down
1 change: 0 additions & 1 deletion src/NearItManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ export class NearItManager {

// Notification history related methods

// TODO: return type
static getNotificationHistory (): Promise<NearItHistoryItem[]> {
return NearItSdk.getNotificationHistory()
}
Expand Down

0 comments on commit 4190ee9

Please sign in to comment.