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

Commit

Permalink
Merge branch 'release/1.2.0-rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoboschini committed Nov 5, 2018
2 parents 7614887 + 3b49c2d commit 534dc66
Show file tree
Hide file tree
Showing 40 changed files with 1,440 additions and 293 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.txt
@@ -1,3 +1,17 @@
1.2.0-rc1 - 11-05-2018

Features:
* Added UIs for coupon list, notification history and single NearIT content.
* Added UIs for permissions request

Enhancements:
* better (un)bundling of NearIT contents

Known issues:
* With Titanium SDK < 7.3.0 some features won't work. There is no way to avoid this, please consider upgrading Titanium SDK.

_____________________________________________

1.1.0-rc1 - 10-23-2018

Features:
Expand Down
68 changes: 24 additions & 44 deletions Titanium-SDK-Sample/Resources/app.js
Expand Up @@ -8,7 +8,7 @@ Ti.API.info("module is => " + NearIT);
Ti.Network.registerForPushNotifications({
success: function(token) {
// give us the token
NearIT.registerForPushNotifications(token.deviceToken);
NearIT.setDeviceToken(token.deviceToken);
},
error: function(e) {
console.log("registerForPushNotifications", e);
Expand Down Expand Up @@ -53,7 +53,11 @@ NearIT.addEventListener(NearIT.NEARIT_EVENTS, function(event) {
}
});

switch (event.contentType) {
// AUTOMAGICALLY SHOW CONTENT
NearIT.showContent(event);

// HANDLE CONTENT MANUALLY
/*switch (event.contentType) {
case NearIT.SIMPLE:
console.log("simple, message:", message);
break;
Expand Down Expand Up @@ -91,7 +95,7 @@ NearIT.addEventListener(NearIT.NEARIT_EVENTS, function(event) {
break;
default:
// Content type unrecognized
}
}*/
});

tabGroup.addTab(createTab1());
Expand All @@ -106,14 +110,8 @@ function createTab1() {
title: "Main"
});

var requestLocation = Ti.UI.createButton({
title: "Location permission and start radar",
color: '#fff',
top: 90
});

var requestNotif = Ti.UI.createButton({
title: "Notification permission",
var requestPermissions = Ti.UI.createButton({
title: "Request permission and start Radar",
color: '#fff',
top: 130
});
Expand Down Expand Up @@ -154,12 +152,20 @@ function createTab1() {
top: 370
});

requestLocation.addEventListener('click', handleLocationPermission);

requestNotif.addEventListener('click', function() {
// REQUEST NOTIFICATION PERMISSION
Ti.App.iOS.registerUserNotificationSettings({
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE , Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND]
requestPermissions.addEventListener('click', function() {
// REQUEST PERMISSIONS AND START RADAR
NearIT.requestPermissions({
explanation: "Give me permissions",
dialogClosed: function(result) {
console.log("dialog closed");
if (result.location) {
console.log("location granted");
NearIT.startRadar();
}
if (result.notifications) {
console.log("notifications granted");
}
}
});
});

Expand Down Expand Up @@ -217,8 +223,7 @@ function createTab1() {
});
});

win.add(requestLocation);
win.add(requestNotif);
win.add(requestPermissions);
win.add(triggerSimple);
win.add(triggerContent);
win.add(triggerFeedback);
Expand Down Expand Up @@ -359,31 +364,6 @@ function createTabProfiling() {
return tab;
}

function handleLocationPermission() {
var hasAlwaysPermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS);
var hasWhenInUsePermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE);
var hasDeniedPermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_DENIED);

if (hasAlwaysPermission) {
// Optimal place to call NearIT.startRadar()
NearIT.startRadar();
} else if (hasWhenInUsePermission) {
// Still a good place to call NearIT.startRadar()
NearIT.startRadar();
} else {
// Should ask for permission
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
if (e.success) {
// OPTIMAL PLACE TO CALL NearIT.startRadar()
NearIT.startRadar();
} else {
// DO NOT start NearIT radar
console.log(e);
}
});
}
}

// added during app creation. this will automatically login to
// ACS for your application and then fire an event (see below)
// when connected or errored. if you do not use ACS in your
Expand Down
44 changes: 44 additions & 0 deletions example/app.js
Expand Up @@ -8,6 +8,43 @@
var NearIT = require('com.nearit.sdk.titanium');


/*
* Register for push notifications AFTER requesting Notification Permission
* - give NearIT plugin the push token
* - let NearIT plugin know when a push notification has been received
*/
Ti.Network.registerForPushNotifications({
success: function(token) {
// give us the token
NearIT.setDeviceToken(token.deviceToken);
},
error: function(e) {
console.log("registerForPushNotifications", e);
},
callback: function(pushNotification) {
// push received
console.log("push callback", pushNotification);
NearIT.didReceiveRemoteNotification(pushNotification);
}
});

/*
* Request permissions
*/
NearIT.requestPermissions({
explanation: "Give me permissions",
dialogClosed: function(result) {
console.log("dialog closed");
if (result.location) {
console.log("location granted");
NearIT.startRadar();
}
if (result.notifications) {
console.log("notifications granted");
}
}
});

/*
* NearIT radar start/stop
* WARNING: you should start radar only when the user already granted location permission
Expand All @@ -29,6 +66,13 @@ NearIT.addEventListener(NearIT.NEARIT_EVENTS, function(event) {
var message = event.content.message;
var trackingInfo = event.trackingInfo;
var content = event.content;

// Automagically show content
NearIT.showContent(event);

// or..

// Manually handle it
switch (event.contentType) {
case NearIT.SIMPLE:
// it's a simple notification with no content
Expand Down
46 changes: 46 additions & 0 deletions ios/Classes/ComNearitConsts.h
@@ -0,0 +1,46 @@
/**
* Titanium-SDK
*
* Created by Federico Boschini
* Copyright (c) 2018 NearIT. All rights reserved.
*/

@interface ComNearitConsts : NSObject

extern NSString* NEARIT_NATIVE_EVENTS_TOPIC;
extern NSString* NEARIT_LOCAL_EVENTS_TOPIC;

// Event types
extern NSString* EVENT_TYPE_SIMPLE;
extern NSString* EVENT_TYPE_CUSTOM_JSON;
extern NSString* EVENT_TYPE_COUPON;
extern NSString* EVENT_TYPE_CONTENT;
extern NSString* EVENT_TYPE_FEEDBACK;

// Events content
extern NSString* EVENT_TYPE;
extern NSString* EVENT_TRACKING_INFO;
extern NSString* EVENT_CONTENT;
extern NSString* EVENT_CONTENT_MESSAGE;
extern NSString* EVENT_CONTENT_DATA;
extern NSString* EVENT_CONTENT_COUPON;
extern NSString* EVENT_CONTENT_TEXT;
extern NSString* EVENT_CONTENT_TITLE;
extern NSString* EVENT_CONTENT_IMAGE;
extern NSString* EVENT_CONTENT_CTA;
extern NSString* EVENT_CONTENT_CTA_LABEL;
extern NSString* EVENT_CONTENT_CTA_LINK;
extern NSString* EVENT_CONTENT_FEEDBACK;
extern NSString* EVENT_CONTENT_QUESTION;
extern NSString* EVENT_STATUS;

// Error codes
extern NSString* E_SEND_FEEDBACK_ERROR;
extern NSString* E_USER_PROFILE_GET_ERROR;
extern NSString* E_USER_PROFILE_SET_ERROR;
extern NSString* E_USER_PROFILE_RESET_ERROR;
extern NSString* E_USER_PROFILE_CREATE_ERROR;
extern NSString* E_USER_PROFILE_DATA_ERROR;
extern NSString* E_COUPONS_RETRIEVAL_ERROR;

@end
48 changes: 48 additions & 0 deletions ios/Classes/ComNearitConsts.m
@@ -0,0 +1,48 @@
/**
* Titanium-SDK
*
* Created by Federico Boschini
* Copyright (c) 2018 NearIT. All rights reserved.
*/

#import "ComNearitConsts.h"

@implementation ComNearitConsts

NSString* NEARIT_NATIVE_EVENTS_TOPIC = @"NearItEvent";
NSString* NEARIT_LOCAL_EVENTS_TOPIC = @"NearItTitaniumLocalEvents";

// Event types
NSString* EVENT_TYPE_SIMPLE = @"NearIt.Events.SimpleNotification";
NSString* EVENT_TYPE_CUSTOM_JSON = @"NearIt.Events.CustomJSON";
NSString* EVENT_TYPE_COUPON = @"NearIt.Events.Coupon";
NSString* EVENT_TYPE_CONTENT = @"NearIt.Events.Content";
NSString* EVENT_TYPE_FEEDBACK = @"NearIt.Events.Feedback";

// Events content
NSString* EVENT_TYPE = @"contentType";
NSString* EVENT_TRACKING_INFO = @"trackingInfo";
NSString* EVENT_CONTENT = @"content";
NSString* EVENT_CONTENT_MESSAGE = @"message";
NSString* EVENT_CONTENT_DATA = @"data";
NSString* EVENT_CONTENT_COUPON = @"coupon";
NSString* EVENT_CONTENT_TEXT = @"text";
NSString* EVENT_CONTENT_TITLE = @"title";
NSString* EVENT_CONTENT_IMAGE = @"image";
NSString* EVENT_CONTENT_CTA = @"cta";
NSString* EVENT_CONTENT_CTA_LABEL = @"label";
NSString* EVENT_CONTENT_CTA_LINK = @"url";
NSString* EVENT_CONTENT_FEEDBACK = @"feedbackId";
NSString* EVENT_CONTENT_QUESTION = @"feedbackQuestion";
NSString* EVENT_STATUS = @"status";

// Error codes
NSString* E_SEND_FEEDBACK_ERROR = @"E_SEND_FEEDBACK_ERROR";
NSString* E_USER_PROFILE_GET_ERROR = @"E_USER_PROFILE_GET_ERROR";
NSString* E_USER_PROFILE_SET_ERROR = @"E_USER_PROFILE_SET_ERROR";
NSString* E_USER_PROFILE_RESET_ERROR = @"E_USER_PROFILE_RESET_ERROR";
NSString* E_USER_PROFILE_CREATE_ERROR = @"E_USER_PROFILE_CREATE_ERROR";
NSString* E_USER_PROFILE_DATA_ERROR = @"E_USER_PROFILE_DATA_ERROR";
NSString* E_COUPONS_RETRIEVAL_ERROR = @"E_COUPONS_RETRIEVAL_ERROR";

@end
6 changes: 5 additions & 1 deletion ios/Classes/ComNearitSdkTitaniumModule.h
Expand Up @@ -8,10 +8,14 @@
#import "TiModule.h"

#import "NearITSDK.h"
#import "ComNearitUI.h"
#import "ComNearitUtils.h"
#import "ComNearitConsts.h"

#import <UserNotifications/UserNotifications.h>


@interface ComNearitSdkTitaniumModule : TiModule<NITManagerDelegate, UNUserNotificationCenterDelegate>
@interface ComNearitSdkTitaniumModule : TiModule<NITManagerDelegate, UNUserNotificationCenterDelegate, NITPermissionsViewControllerDelegate>
{

}
Expand Down

0 comments on commit 534dc66

Please sign in to comment.