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/2.9.0-beta.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoboschini committed Aug 2, 2018
2 parents 7141653 + 80c7842 commit bc7514d
Show file tree
Hide file tree
Showing 20 changed files with 3,341 additions and 107 deletions.
13 changes: 7 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:3.1.3'
}
}


allprojects {
repositories {
jcenter()
maven { url "$projectDir/../node_modules/react-native/android" }
jcenter()
maven { url "https://maven.google.com" }
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
minSdkVersion 16
Expand All @@ -43,6 +44,6 @@ android {
}

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'it.near.sdk:nearit:2.7.0'
implementation 'com.facebook.react:react-native:+'
api 'it.near.sdk:nearit:2.9.4'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package it.near.sdk.reactnative.rnnearitsdk;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand Down Expand Up @@ -38,12 +39,12 @@
import it.near.sdk.NearItManager;
import it.near.sdk.communication.OptOutNotifier;
import it.near.sdk.operation.NearItUserProfile;
import it.near.sdk.operation.values.NearMultipleChoiceDataPoint;
import it.near.sdk.reactions.couponplugin.CouponListener;
import it.near.sdk.reactions.couponplugin.model.Coupon;
import it.near.sdk.reactions.feedbackplugin.FeedbackEvent;
import it.near.sdk.reactions.feedbackplugin.model.Feedback;
import it.near.sdk.recipes.NearITEventHandler;
import it.near.sdk.recipes.RecipeRefreshListener;
import it.near.sdk.recipes.foreground.ProximityListener;
import it.near.sdk.recipes.models.Recipe;
import it.near.sdk.trackings.TrackingInfo;
Expand All @@ -60,6 +61,7 @@ public class RNNearItModule extends ReactContextBaseJavaModule implements Lifecy
static final String NATIVE_EVENTS_TOPIC = "RNNearItEvent";
private static final String NATIVE_PERMISSIONS_TOPIC = "RNNearItPermissions";

@SuppressWarnings("WeakerAccess")
// Local Events topic (used by LocalBroadcastReceiver to handle foreground notifications)
static final String LOCAL_EVENTS_TOPIC = "RNNearItLocalEvents";

Expand Down Expand Up @@ -93,7 +95,6 @@ public class RNNearItModule extends ReactContextBaseJavaModule implements Lifecy
private static final String PERMISSION_LOCATION_DENIED = "NearIt.Permissions.Location.Denied";

// Error codes
private static final String E_REFRESH_CONFIG_ERROR = "E_REFRESH_CONFIG_ERROR";
private static final String E_START_RADAR_ERROR = "E_START_RADAR_ERROR";
private static final String E_STOP_RADAR_ERROR = "E_STOP_RADAR_ERROR";
private static final String E_SEND_TRACKING_ERROR = "E_SEND_TRACKING_ERROR";
Expand All @@ -106,7 +107,7 @@ public class RNNearItModule extends ReactContextBaseJavaModule implements Lifecy
private static final String E_COUPONS_RETRIEVAL_ERROR = "E_COUPONS_RETRIEVAL_ERROR";
private static final String E_OPT_OUT_ERROR = "E_OPT_OUT_ERROR";


@SuppressWarnings("WeakerAccess")
public RNNearItModule(ReactApplicationContext reactContext) {
super(reactContext);

Expand Down Expand Up @@ -174,8 +175,8 @@ private Map<String, Object> getEventContentConstants() {
private Map<String, Object> getStatusConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("notified", Recipe.NOTIFIED_STATUS);
put("engaged", Recipe.ENGAGED_STATUS);
put("notified", Recipe.RECEIVED);
put("engaged", Recipe.OPENED);
}
});
}
Expand All @@ -191,6 +192,7 @@ private Map<String, Object> getPermissionStatusConstants() {
});
}

@SuppressWarnings("unused")
public static void onPostCreate(Context context, Intent intent) {
if (NearUtils.carriesNearItContent(intent)) {
NearUtils.parseContents(intent, new RNNearItCoreContentsListener(context, null, true));
Expand Down Expand Up @@ -227,6 +229,7 @@ public void onNewIntent(Intent intent) {
}

// ReactNative listeners management
@SuppressWarnings("unused")
@ReactMethod
public void listenerRegistered(final Promise promise) {
final int listenersCount = RNNearItPersistedQueue.defaultQueue().registerListener();
Expand All @@ -235,6 +238,7 @@ public void listenerRegistered(final Promise promise) {
promise.resolve(true);
}

@SuppressWarnings("unused")
@ReactMethod
public void listenerUnregistered(final Promise promise) {
final int listenersCount = RNNearItPersistedQueue.defaultQueue().unregisterListener();
Expand All @@ -248,23 +252,9 @@ public void foregroundEvent(Parcelable parcelable, TrackingInfo trackingInfo) {
NearUtils.parseContents(parcelable, trackingInfo, new RNNearItCoreContentsListener(getReactApplicationContext(), getRCTDeviceEventEmitter(), false));
}

// NearIT Config
@ReactMethod
public void refreshConfig(final Promise promise) {
NearItManager.getInstance().refreshConfigs(new RecipeRefreshListener() {
@Override
public void onRecipesRefresh() {
promise.resolve(null);
}

@Override
public void onRecipesRefreshFail() {
promise.reject(E_REFRESH_CONFIG_ERROR, "refreshConfig failed");
}
});
}

// NearIT Radar
@SuppressWarnings("unused")
@SuppressLint("MissingPermission")
@ReactMethod
public void startRadar(final Promise promise) {
try {
Expand All @@ -275,6 +265,7 @@ public void startRadar(final Promise promise) {
}
}

@SuppressWarnings("unused")
@ReactMethod
public void stopRadar(final Promise promise) {
try {
Expand All @@ -286,6 +277,7 @@ public void stopRadar(final Promise promise) {
}

// NearIT Trackings
@SuppressWarnings("unused")
@ReactMethod
public void sendTracking(final String trackinInfoData, final String status, final Promise promise) {
try {
Expand All @@ -299,6 +291,7 @@ public void sendTracking(final String trackinInfoData, final String status, fina
}

// NearIT Feedback
@SuppressWarnings("unused")
@ReactMethod
public void sendFeedback(final String feedbackB64, final int rating, final String comment, final Promise promise) {
final Feedback feedback;
Expand All @@ -322,6 +315,7 @@ public void onFail(int errorCode, String errorMessage) {
}

// NearIT UserProfiling
@SuppressWarnings("unused")
@ReactMethod
public void getUserProfileId(final Promise promise) {
NearItManager.getInstance().getProfileId(new NearItUserProfile.ProfileFetchListener() {
Expand All @@ -337,6 +331,7 @@ public void onError(String error) {
});
}

@SuppressWarnings("unused")
@ReactMethod
public void setUserProfileId(final String profileId, final Promise promise) {
try {
Expand All @@ -347,6 +342,7 @@ public void setUserProfileId(final String profileId, final Promise promise) {
}
}

@SuppressWarnings("unused")
@ReactMethod
public void resetUserProfile(final Promise promise) {
NearItManager.getInstance().resetProfileId(new NearItUserProfile.ProfileFetchListener() {
Expand All @@ -362,6 +358,7 @@ public void onError(String error) {
});
}

@SuppressWarnings("unused")
@ReactMethod
public void setUserData(final ReadableMap userData, final Promise promise) {
try {
Expand All @@ -374,6 +371,44 @@ public void setUserData(final ReadableMap userData, final Promise promise) {
}
}

@SuppressWarnings("unused")
@ReactMethod
public void setUserData(final String key, final String value, final Promise promise) {
try {
Log.d("RNNearItModule", "setting user data: "+key+", "+value);
NearItManager.getInstance().setUserData(key, value);
promise.resolve(null);
} catch (Exception e) {
promise.reject(E_USER_PROFILE_DATA_ERROR, "Error while setting userData");
}
}

@SuppressWarnings("unused")
@ReactMethod
public void setMultiChoiceUserData(final String key, final ReadableMap userData, final Promise promise) {
try {
NearMultipleChoiceDataPoint multiChoiceData = null;
HashMap<String, Boolean> data = new HashMap<>();
if (userData != null) {
for (Map.Entry<String, Object> entry : userData.toHashMap().entrySet()) {
if(entry.getValue() instanceof Boolean){
data.put(entry.getKey(), (Boolean) entry.getValue());
}
}
}
if (!data.isEmpty()) {
multiChoiceData = new NearMultipleChoiceDataPoint(data);
}

Log.d("RNNearItModule", "setting user data: "+key+", "+data);
NearItManager.getInstance().setUserData(key, multiChoiceData);
promise.resolve(null);
} catch (Exception e) {
promise.reject(E_USER_PROFILE_DATA_ERROR, "Error while setting userData");
}
}

@SuppressWarnings("unused")
@ReactMethod
public void optOut(final Promise promise) {
NearItManager.getInstance().optOut(new OptOutNotifier() {
Expand All @@ -391,38 +426,43 @@ public void onFailure(String error) {

// NearIT Permissions request

@SuppressWarnings("unused")
@ReactMethod
public void checkNotificationPermission(final Promise promise) {
promise.resolve(true);
}

@SuppressWarnings("unused")
@ReactMethod
public void requestNotificationPermission(final Promise promise) {
promise.resolve(true);
}

@SuppressWarnings("unused")
@ReactMethod
public void checkLocationPermission(final Promise promise) {
promise.resolve(true);
}

@SuppressWarnings("unused")
@ReactMethod
public void requestLocationPermission(final Promise promise) {
promise.resolve(true);
}

// NearIT Custom Trigger

@SuppressWarnings("unused")
@ReactMethod
public void triggerEvent(final String eventKey, final Promise promise) {
// Trigger Custom Event Key
NearItManager.getInstance().processCustomTrigger(eventKey);
NearItManager.getInstance().triggerInAppEvent(eventKey);
// Resolve null, if a Recipe is triggered then the normal notification flow will run
promise.resolve(null);
}

// NearIT Coupons

@SuppressWarnings("unused")
@ReactMethod
public void getCoupons(final Promise promise) {
NearItManager.getInstance().getCoupons(new CouponListener() {
Expand Down Expand Up @@ -467,6 +507,7 @@ private DeviceEventManagerModule.RCTDeviceEventEmitter getRCTDeviceEventEmitter(
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
}

@SuppressWarnings("unused")
private void sendEventWithLocationPermissionStatus(final String permissionStatus) {
try {
// Create Event map to send to JS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import it.near.sdk.NearItManager;

@SuppressWarnings("unused")
public class RNNearItPackage implements ReactPackage {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package it.near.sdk.reactnative.rnnearitsdk;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
Expand Down Expand Up @@ -76,6 +77,7 @@ static void addNotification(final Context context, final WritableMap notificatio
}
}

@SuppressLint("ApplySharedPref")
static void dispatchNotificationsQueue(final Context context, RNNearItPersistedQueue.NotificationDispatcher dispatcher) {
if (!defaultQueue().hasListeners()) {
// Should not be here if there are no listeners
Expand Down
Loading

0 comments on commit bc7514d

Please sign in to comment.