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

Commit 4190ee9

Browse files
Merge branch 'hotfix/v2.12.0'
2 parents 7d5fc47 + 7950dea commit 4190ee9

File tree

8 files changed

+48
-24
lines changed

8 files changed

+48
-24
lines changed

RNNearIt.podspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
2020
s.ios.deployment_target = '9.0'
2121

2222
s.dependency 'React'
23-
s.dependency 'NearITSDK', '~> 2.12.0'
24-
s.dependency 'NearITSDKSwift', '~> 2.12.0'
25-
s.dependency 'NearUIBinding', '~> 2.12.0'
23+
s.dependency 'NearITSDK', '~> 2.12.1'
24+
s.dependency 'NearITSDKSwift', '~> 2.12.1'
25+
s.dependency 'NearUIBinding', '~> 2.12.1'
2626
end

android/src/main/java/it/near/sdk/reactnative/rnnearitsdk/RNNearItModule.java

-2
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,10 @@ private Map<String, Object> getPermissionsConstants() {
175175
// ReactApp Lifecycle methods
176176
@Override
177177
public void onHostResume() {
178-
// TODO: remove this? -> this.dispatchNotificationQueue();
179178
}
180179

181180
@Override
182181
public void onHostPause() {
183-
184182
}
185183

186184
@Override

ios/RNNearIt.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ - (BOOL)application:(UIApplication* _Nonnull)application didReceiveLocalNotifica
234234

235235
RCT_EXPORT_METHOD(addProximityListener)
236236
{
237-
[NITManager defaultManager].delegate = self;
237+
NITLogD(TAG, @"addProximityListener::method called but nothing to do on iOS");
238238
}
239239

240240
RCT_EXPORT_METHOD(removeProximityListener)
241241
{
242-
[NITManager defaultManager].delegate = nil;
242+
NITLogD(TAG, @"removeProximityListener::method called but nothing to do on iOS");
243243
}
244244

245245
// MARK: ReactNative listeners management
@@ -576,6 +576,8 @@ - (void)loadConfig
576576

577577
// Set NearIT framework name
578578
[NITManager setFrameworkName:@"react-native"];
579+
580+
[NITManager defaultManager].delegate = self;
579581
}
580582

581583
- (void)sendEventWithContent:(NSDictionary* _Nonnull)content NITEventType:(NSString* _Nonnull)eventType trackingInfo:(NITTrackingInfo* _Nullable)trackingInfo fromUserAction:(BOOL)fromUserAction

ios/RNNearItUI.m

+9-8
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ - (void)dialogClosedWithLocationGranted:(BOOL)locationGranted notificationsGrant
4040
}
4141

4242
- (void)locationGranted:(BOOL)granted {
43-
// TODO: nothing?
43+
4444
}
4545

4646
- (void)notificationsGranted:(BOOL)granted {
47-
// TODO: nothing?
47+
4848
}
4949

5050

@@ -84,7 +84,7 @@ - (void)notificationsGranted:(BOOL)granted {
8484

8585
// MARK: Coupon related methods
8686

87-
RCT_EXPORT_METHOD(showCoupons: (NSString* _Nullable) title)
87+
RCT_EXPORT_METHOD(showCouponList: (NSString* _Nullable) title)
8888
{
8989
NITCouponListViewController *couponsVC = [[NITCouponListViewController alloc] init];
9090
if (title != nil) {
@@ -96,13 +96,14 @@ - (void)notificationsGranted:(BOOL)granted {
9696

9797
// MARK: Content related methods
9898

99-
RCT_EXPORT_METHOD(showContent: (NSDictionary* _Nullable) content)
99+
RCT_EXPORT_METHOD(showContent: (NSDictionary* _Nullable) event)
100100
{
101-
if (content != nil) {
102-
NSString* type = [content objectForKey:EVENT_TYPE];
101+
if (event != nil) {
102+
NSString* type = [event objectForKey:EVENT_TYPE];
103+
NSDictionary* content = [event objectForKey:EVENT_CONTENT];
103104
if ([type isEqualToString:EVENT_TYPE_CONTENT]) {
104105
NITContent* nearContent = [RNNearItUtils unbundleNITContent:content];
105-
NITTrackingInfo* trackingInfo = [RNNearItUtils unbundleTrackingInfo:[content objectForKey:EVENT_TRACKING_INFO]];
106+
NITTrackingInfo* trackingInfo = [RNNearItUtils unbundleTrackingInfo:[event objectForKey:EVENT_TRACKING_INFO]];
106107
NITContentViewController *vc = [[NITContentViewController alloc] initWithContent:nearContent trackingInfo:trackingInfo];
107108
[vc show];
108109
} else if ([type isEqualToString:EVENT_TYPE_FEEDBACK]) {
@@ -137,7 +138,7 @@ - (NSDictionary*)getPermissionsStatus:(BOOL)notificationGranted
137138
return @{
138139
PERMISSIONS_LOCATION_PERMISSION: @(locationGranted),
139140
PERMISSIONS_NOTIFICATIONS_PERMISSION: @(notificationGranted),
140-
PERMISSIONS_BLUETOOTH: @NO,
141+
PERMISSIONS_BLUETOOTH: @YES,
141142
PERMISSIONS_LOCATION_SERVICES: @(locationServicesOn)
142143
};
143144
}

ios/RNNearItUtils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
+ (NSDictionary* _Nullable)bundleNITContent:(NITContent* _Nonnull)content;
2626
+ (NITContent* _Nullable)unbundleNITContent:(NSDictionary* _Nonnull)bundledContent;
2727

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

3030
+ (NSDictionary* _Nullable)bundleNITFeedback:(NITFeedback* _Nonnull)feedback;
3131
+ (NITFeedback* _Nullable)unbundleNITFeedback:(NSDictionary* _Nonnull)bundledFeedback;

ios/RNNearItUtils.m

+30-6
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,31 @@ + (NSDictionary* _Nullable)bundleNITContent:(NITContent * _Nonnull) content
119119
+ (NITContent* _Nullable)unbundleNITContent:(NSDictionary * _Nonnull)bundledContent
120120
{
121121
NITContent* content = [[NITContent alloc] init];
122-
content.title = [bundledContent objectForKey:EVENT_CONTENT_TITLE];
123-
content.content = [bundledContent objectForKey:EVENT_CONTENT_TEXT];
124-
content.images = @[[self unbundleNITImage: [bundledContent objectForKey:EVENT_IMAGE]]];
125-
content.internalLink = [bundledContent objectForKey:EVENT_CONTENT_CTA];
122+
123+
NSObject* bundledTitle = [bundledContent objectForKey:EVENT_CONTENT_TITLE];
124+
if ([bundledTitle isEqual:[NSNull null]]) {
125+
content.title = nil;
126+
} else {
127+
content.title = [bundledContent objectForKey:EVENT_CONTENT_TITLE];
128+
}
129+
130+
NSObject* bundledText = [bundledContent objectForKey:EVENT_CONTENT_TEXT];
131+
if ([bundledText isEqual:[NSNull null]]) {
132+
content.content = nil;
133+
} else {
134+
content.content = [bundledContent objectForKey:EVENT_CONTENT_TEXT];
135+
}
136+
137+
NITImage* unbundledImage = [self unbundleNITImage: [bundledContent objectForKey:EVENT_IMAGE]];
138+
if (unbundledImage) {
139+
content.images = @[unbundledImage];
140+
}
141+
142+
NSObject* bundledCTA = [bundledContent objectForKey:EVENT_CONTENT_CTA];
143+
if (![bundledCTA isEqual:[NSNull null]]) {
144+
content.internalLink = [bundledContent objectForKey:EVENT_CONTENT_CTA];
145+
}
146+
126147
return content;
127148
}
128149

@@ -174,6 +195,9 @@ + (NSDictionary* _Nullable)bundleNITImage:(NITImage* _Nonnull)image
174195

175196
+ (NITImage* _Nullable)unbundleNITImage:(NSDictionary* _Nonnull)bundledImage
176197
{
198+
if ([bundledImage isEqual:[NSNull null]]) {
199+
return nil;
200+
}
177201
NITImage* image = [[NITImage alloc] init];
178202
if ([bundledImage objectForKey:@"imageData"]) {
179203
NSData* imageData = [[NSData alloc] initWithBase64EncodedString:[bundledImage objectForKey:@"imageData"]
@@ -195,9 +219,9 @@ + (NSDictionary* _Nullable)bundleNITContentLink:(NITContentLink* _Nonnull)cta
195219

196220
// NITHistory
197221

198-
+ (NSArray* _Nullable)bundleNITHistory:(NSArray<NITHistoryItem*>* _Nonnull)history
222+
+ (NSArray* _Nonnull)bundleNITHistory:(NSArray<NITHistoryItem*>* _Nonnull)history
199223
{
200-
NSMutableArray* bundledHistory;
224+
NSMutableArray* bundledHistory = [NSMutableArray new];
201225
for (id item in history) {
202226
[bundledHistory addObject:[self bundleNITHistoryItem:item]];
203227
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-nearit",
3-
"version": "2.12.0-alpha.7",
3+
"version": "2.12.0",
44
"author": "Mattia Panzeri <[email protected]>",
55
"contributors": [
66
"Federico Boschini <[email protected]>"

src/NearItManager.js

-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ export class NearItManager {
221221

222222
// Notification history related methods
223223

224-
// TODO: return type
225224
static getNotificationHistory (): Promise<NearItHistoryItem[]> {
226225
return NearItSdk.getNotificationHistory()
227226
}

0 commit comments

Comments
 (0)