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

Commit 534dc66

Browse files
Merge branch 'release/1.2.0-rc1'
2 parents 7614887 + 3b49c2d commit 534dc66

40 files changed

+1440
-293
lines changed

CHANGELOG.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
1.2.0-rc1 - 11-05-2018
2+
3+
Features:
4+
* Added UIs for coupon list, notification history and single NearIT content.
5+
* Added UIs for permissions request
6+
7+
Enhancements:
8+
* better (un)bundling of NearIT contents
9+
10+
Known issues:
11+
* With Titanium SDK < 7.3.0 some features won't work. There is no way to avoid this, please consider upgrading Titanium SDK.
12+
13+
_____________________________________________
14+
115
1.1.0-rc1 - 10-23-2018
216

317
Features:

Titanium-SDK-Sample/Resources/app.js

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Ti.API.info("module is => " + NearIT);
88
Ti.Network.registerForPushNotifications({
99
success: function(token) {
1010
// give us the token
11-
NearIT.registerForPushNotifications(token.deviceToken);
11+
NearIT.setDeviceToken(token.deviceToken);
1212
},
1313
error: function(e) {
1414
console.log("registerForPushNotifications", e);
@@ -53,7 +53,11 @@ NearIT.addEventListener(NearIT.NEARIT_EVENTS, function(event) {
5353
}
5454
});
5555

56-
switch (event.contentType) {
56+
// AUTOMAGICALLY SHOW CONTENT
57+
NearIT.showContent(event);
58+
59+
// HANDLE CONTENT MANUALLY
60+
/*switch (event.contentType) {
5761
case NearIT.SIMPLE:
5862
console.log("simple, message:", message);
5963
break;
@@ -91,7 +95,7 @@ NearIT.addEventListener(NearIT.NEARIT_EVENTS, function(event) {
9195
break;
9296
default:
9397
// Content type unrecognized
94-
}
98+
}*/
9599
});
96100

97101
tabGroup.addTab(createTab1());
@@ -106,14 +110,8 @@ function createTab1() {
106110
title: "Main"
107111
});
108112

109-
var requestLocation = Ti.UI.createButton({
110-
title: "Location permission and start radar",
111-
color: '#fff',
112-
top: 90
113-
});
114-
115-
var requestNotif = Ti.UI.createButton({
116-
title: "Notification permission",
113+
var requestPermissions = Ti.UI.createButton({
114+
title: "Request permission and start Radar",
117115
color: '#fff',
118116
top: 130
119117
});
@@ -154,12 +152,20 @@ function createTab1() {
154152
top: 370
155153
});
156154

157-
requestLocation.addEventListener('click', handleLocationPermission);
158-
159-
requestNotif.addEventListener('click', function() {
160-
// REQUEST NOTIFICATION PERMISSION
161-
Ti.App.iOS.registerUserNotificationSettings({
162-
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE , Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND]
155+
requestPermissions.addEventListener('click', function() {
156+
// REQUEST PERMISSIONS AND START RADAR
157+
NearIT.requestPermissions({
158+
explanation: "Give me permissions",
159+
dialogClosed: function(result) {
160+
console.log("dialog closed");
161+
if (result.location) {
162+
console.log("location granted");
163+
NearIT.startRadar();
164+
}
165+
if (result.notifications) {
166+
console.log("notifications granted");
167+
}
168+
}
163169
});
164170
});
165171

@@ -217,8 +223,7 @@ function createTab1() {
217223
});
218224
});
219225

220-
win.add(requestLocation);
221-
win.add(requestNotif);
226+
win.add(requestPermissions);
222227
win.add(triggerSimple);
223228
win.add(triggerContent);
224229
win.add(triggerFeedback);
@@ -359,31 +364,6 @@ function createTabProfiling() {
359364
return tab;
360365
}
361366

362-
function handleLocationPermission() {
363-
var hasAlwaysPermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
364-
var hasWhenInUsePermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE);
365-
var hasDeniedPermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_DENIED);
366-
367-
if (hasAlwaysPermission) {
368-
// Optimal place to call NearIT.startRadar()
369-
NearIT.startRadar();
370-
} else if (hasWhenInUsePermission) {
371-
// Still a good place to call NearIT.startRadar()
372-
NearIT.startRadar();
373-
} else {
374-
// Should ask for permission
375-
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
376-
if (e.success) {
377-
// OPTIMAL PLACE TO CALL NearIT.startRadar()
378-
NearIT.startRadar();
379-
} else {
380-
// DO NOT start NearIT radar
381-
console.log(e);
382-
}
383-
});
384-
}
385-
}
386-
387367
// added during app creation. this will automatically login to
388368
// ACS for your application and then fire an event (see below)
389369
// when connected or errored. if you do not use ACS in your

example/app.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,43 @@
88
var NearIT = require('com.nearit.sdk.titanium');
99

1010

11+
/*
12+
* Register for push notifications AFTER requesting Notification Permission
13+
* - give NearIT plugin the push token
14+
* - let NearIT plugin know when a push notification has been received
15+
*/
16+
Ti.Network.registerForPushNotifications({
17+
success: function(token) {
18+
// give us the token
19+
NearIT.setDeviceToken(token.deviceToken);
20+
},
21+
error: function(e) {
22+
console.log("registerForPushNotifications", e);
23+
},
24+
callback: function(pushNotification) {
25+
// push received
26+
console.log("push callback", pushNotification);
27+
NearIT.didReceiveRemoteNotification(pushNotification);
28+
}
29+
});
30+
31+
/*
32+
* Request permissions
33+
*/
34+
NearIT.requestPermissions({
35+
explanation: "Give me permissions",
36+
dialogClosed: function(result) {
37+
console.log("dialog closed");
38+
if (result.location) {
39+
console.log("location granted");
40+
NearIT.startRadar();
41+
}
42+
if (result.notifications) {
43+
console.log("notifications granted");
44+
}
45+
}
46+
});
47+
1148
/*
1249
* NearIT radar start/stop
1350
* WARNING: you should start radar only when the user already granted location permission
@@ -29,6 +66,13 @@ NearIT.addEventListener(NearIT.NEARIT_EVENTS, function(event) {
2966
var message = event.content.message;
3067
var trackingInfo = event.trackingInfo;
3168
var content = event.content;
69+
70+
// Automagically show content
71+
NearIT.showContent(event);
72+
73+
// or..
74+
75+
// Manually handle it
3276
switch (event.contentType) {
3377
case NearIT.SIMPLE:
3478
// it's a simple notification with no content

ios/Classes/ComNearitConsts.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Titanium-SDK
3+
*
4+
* Created by Federico Boschini
5+
* Copyright (c) 2018 NearIT. All rights reserved.
6+
*/
7+
8+
@interface ComNearitConsts : NSObject
9+
10+
extern NSString* NEARIT_NATIVE_EVENTS_TOPIC;
11+
extern NSString* NEARIT_LOCAL_EVENTS_TOPIC;
12+
13+
// Event types
14+
extern NSString* EVENT_TYPE_SIMPLE;
15+
extern NSString* EVENT_TYPE_CUSTOM_JSON;
16+
extern NSString* EVENT_TYPE_COUPON;
17+
extern NSString* EVENT_TYPE_CONTENT;
18+
extern NSString* EVENT_TYPE_FEEDBACK;
19+
20+
// Events content
21+
extern NSString* EVENT_TYPE;
22+
extern NSString* EVENT_TRACKING_INFO;
23+
extern NSString* EVENT_CONTENT;
24+
extern NSString* EVENT_CONTENT_MESSAGE;
25+
extern NSString* EVENT_CONTENT_DATA;
26+
extern NSString* EVENT_CONTENT_COUPON;
27+
extern NSString* EVENT_CONTENT_TEXT;
28+
extern NSString* EVENT_CONTENT_TITLE;
29+
extern NSString* EVENT_CONTENT_IMAGE;
30+
extern NSString* EVENT_CONTENT_CTA;
31+
extern NSString* EVENT_CONTENT_CTA_LABEL;
32+
extern NSString* EVENT_CONTENT_CTA_LINK;
33+
extern NSString* EVENT_CONTENT_FEEDBACK;
34+
extern NSString* EVENT_CONTENT_QUESTION;
35+
extern NSString* EVENT_STATUS;
36+
37+
// Error codes
38+
extern NSString* E_SEND_FEEDBACK_ERROR;
39+
extern NSString* E_USER_PROFILE_GET_ERROR;
40+
extern NSString* E_USER_PROFILE_SET_ERROR;
41+
extern NSString* E_USER_PROFILE_RESET_ERROR;
42+
extern NSString* E_USER_PROFILE_CREATE_ERROR;
43+
extern NSString* E_USER_PROFILE_DATA_ERROR;
44+
extern NSString* E_COUPONS_RETRIEVAL_ERROR;
45+
46+
@end

ios/Classes/ComNearitConsts.m

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Titanium-SDK
3+
*
4+
* Created by Federico Boschini
5+
* Copyright (c) 2018 NearIT. All rights reserved.
6+
*/
7+
8+
#import "ComNearitConsts.h"
9+
10+
@implementation ComNearitConsts
11+
12+
NSString* NEARIT_NATIVE_EVENTS_TOPIC = @"NearItEvent";
13+
NSString* NEARIT_LOCAL_EVENTS_TOPIC = @"NearItTitaniumLocalEvents";
14+
15+
// Event types
16+
NSString* EVENT_TYPE_SIMPLE = @"NearIt.Events.SimpleNotification";
17+
NSString* EVENT_TYPE_CUSTOM_JSON = @"NearIt.Events.CustomJSON";
18+
NSString* EVENT_TYPE_COUPON = @"NearIt.Events.Coupon";
19+
NSString* EVENT_TYPE_CONTENT = @"NearIt.Events.Content";
20+
NSString* EVENT_TYPE_FEEDBACK = @"NearIt.Events.Feedback";
21+
22+
// Events content
23+
NSString* EVENT_TYPE = @"contentType";
24+
NSString* EVENT_TRACKING_INFO = @"trackingInfo";
25+
NSString* EVENT_CONTENT = @"content";
26+
NSString* EVENT_CONTENT_MESSAGE = @"message";
27+
NSString* EVENT_CONTENT_DATA = @"data";
28+
NSString* EVENT_CONTENT_COUPON = @"coupon";
29+
NSString* EVENT_CONTENT_TEXT = @"text";
30+
NSString* EVENT_CONTENT_TITLE = @"title";
31+
NSString* EVENT_CONTENT_IMAGE = @"image";
32+
NSString* EVENT_CONTENT_CTA = @"cta";
33+
NSString* EVENT_CONTENT_CTA_LABEL = @"label";
34+
NSString* EVENT_CONTENT_CTA_LINK = @"url";
35+
NSString* EVENT_CONTENT_FEEDBACK = @"feedbackId";
36+
NSString* EVENT_CONTENT_QUESTION = @"feedbackQuestion";
37+
NSString* EVENT_STATUS = @"status";
38+
39+
// Error codes
40+
NSString* E_SEND_FEEDBACK_ERROR = @"E_SEND_FEEDBACK_ERROR";
41+
NSString* E_USER_PROFILE_GET_ERROR = @"E_USER_PROFILE_GET_ERROR";
42+
NSString* E_USER_PROFILE_SET_ERROR = @"E_USER_PROFILE_SET_ERROR";
43+
NSString* E_USER_PROFILE_RESET_ERROR = @"E_USER_PROFILE_RESET_ERROR";
44+
NSString* E_USER_PROFILE_CREATE_ERROR = @"E_USER_PROFILE_CREATE_ERROR";
45+
NSString* E_USER_PROFILE_DATA_ERROR = @"E_USER_PROFILE_DATA_ERROR";
46+
NSString* E_COUPONS_RETRIEVAL_ERROR = @"E_COUPONS_RETRIEVAL_ERROR";
47+
48+
@end

ios/Classes/ComNearitSdkTitaniumModule.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
#import "TiModule.h"
99

1010
#import "NearITSDK.h"
11+
#import "ComNearitUI.h"
12+
#import "ComNearitUtils.h"
13+
#import "ComNearitConsts.h"
14+
1115
#import <UserNotifications/UserNotifications.h>
1216

1317

14-
@interface ComNearitSdkTitaniumModule : TiModule<NITManagerDelegate, UNUserNotificationCenterDelegate>
18+
@interface ComNearitSdkTitaniumModule : TiModule<NITManagerDelegate, UNUserNotificationCenterDelegate, NITPermissionsViewControllerDelegate>
1519
{
1620

1721
}

0 commit comments

Comments
 (0)