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

Commit

Permalink
Merge pull request #14 from panz3r/master
Browse files Browse the repository at this point in the history
Update `NearIT SDK`s to latest versions
  • Loading branch information
Mattia Panzeri authored Oct 13, 2017
2 parents 5c1e17e + f000bd7 commit 72d2681
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 258 deletions.
2 changes: 1 addition & 1 deletion RNNearIt.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ Pod::Spec.new do |s|
s.requires_arc = true

s.dependency "React"
s.dependency "NearITSDK", "2.2.4"
s.dependency "NearITSDK", "2.2.5"
end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ android {

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'it.near.sdk:nearit:2.2.7'
compile 'it.near.sdk:nearit:2.2.8'
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import it.near.sdk.NearItManager;
import it.near.sdk.geopolis.beacons.ranging.ProximityListener;
import it.near.sdk.operation.NearItUserProfile;
import it.near.sdk.operation.UserDataNotifier;
import it.near.sdk.reactions.couponplugin.CouponListener;
import it.near.sdk.reactions.couponplugin.model.Coupon;
Expand Down Expand Up @@ -310,13 +311,17 @@ public void onFail(int errorCode, String errorMessage) {
// NearIT UserProfiling
@ReactMethod
public void getUserProfileId(final Promise promise) {
final String profileId;
try {
profileId = NearItManager.getInstance().getProfileId();
promise.resolve(profileId);
} catch (Exception e) {
promise.reject(E_USER_PROFILE_GET_ERROR, e);
}
NearItManager.getInstance().getProfileId(new NearItUserProfile.ProfileFetchListener() {
@Override
public void onProfileId(String profileId) {
promise.resolve(profileId);
}

@Override
public void onError(String error) {
promise.reject(E_USER_PROFILE_GET_ERROR, error);
}
});
}

@ReactMethod
Expand All @@ -331,12 +336,17 @@ public void setUserProfileId(final String profileId, final Promise promise) {

@ReactMethod
public void resetUserProfile(final Promise promise) {
try {
NearItManager.getInstance().resetProfileId();
promise.resolve(null);
} catch (Exception e) {
promise.reject(E_USER_PROFILE_RESET_ERROR, e);
}
NearItManager.getInstance().resetProfileId(new NearItUserProfile.ProfileFetchListener() {
@Override
public void onProfileId(String profileId) {
promise.resolve(profileId);
}

@Override
public void onError(String error) {
promise.reject(E_USER_PROFILE_RESET_ERROR, error);
}
});
}

@ReactMethod
Expand Down
39 changes: 30 additions & 9 deletions ios/RNNearIt.m
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,13 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu
RCT_EXPORT_METHOD(getUserProfileId: (RCTPromiseResolveBlock) resolve
rejection: (RCTPromiseRejectBlock) reject)
{
resolve([[NITManager defaultManager] profileId]);
[[NITManager defaultManager] profileIdWithCompletionHandler:^(NSString * _Nullable profileId, NSError * _Nullable error) {
if (!error) {
resolve(profileId);
} else {
reject(E_USER_PROFILE_GET_ERROR, @"Could not get UserProfile", error);
}
}];
}

RCT_EXPORT_METHOD(setUserProfileId: (NSString* _Nonnull) profileId
Expand All @@ -337,8 +343,13 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu
RCT_EXPORT_METHOD(resetUserProfile: (RCTPromiseResolveBlock) resolve
rejection: (RCTPromiseRejectBlock) reject)
{
[[NITManager defaultManager] resetProfile];
resolve([NSNull null]);
[[NITManager defaultManager] resetProfileWithCompletionHandler:^(NSString * _Nullable profileId, NSError * _Nullable error) {
if (!error) {
resolve(profileId);
} else {
reject(E_USER_PROFILE_RESET_ERROR, @"Could not reset UserProfile", error);
}
}];
}

RCT_EXPORT_METHOD(setUserData: (NSDictionary* _Nonnull) userData
Expand All @@ -356,14 +367,19 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu

// MARK: NearIT Permissions request

-(BOOL)hasLocationPermission {
return CLLocationManager.authorizationStatus == kCLAuthorizationStatusAuthorizedAlways;
}

RCT_EXPORT_METHOD(checkNotificationPermission:(RCTPromiseResolveBlock)resolve
rejection:(RCTPromiseRejectBlock)reject)
{
NITLogD(TAG, @"checkNotificationPermission");

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
UIUserNotificationSettings* notificationSettings = [RCTSharedApplication() currentUserNotificationSettings];
resolve(@(notificationSettings != UIUserNotificationTypeNone));
BOOL notificationAuthorized = notificationSettings != UIUserNotificationTypeNone;
resolve(@(notificationAuthorized));
} else {
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
[[UNUserNotificationCenter currentNotificationCenter]getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
Expand All @@ -373,9 +389,11 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu
resolve([NSNull null]);
break;

default:
resolve(@(settings.authorizationStatus == UNAuthorizationStatusAuthorized));
default: {
BOOL notificationPermission = settings.authorizationStatus == UNAuthorizationStatusAuthorized;
resolve(@(notificationPermission));
break;
}
}
}];
#endif
Expand Down Expand Up @@ -414,6 +432,7 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu
}

#if !TARGET_IPHONE_SIMULATOR
// Register Push notifications token only on real devices
NITLogV(TAG, @"registerForRemoteNotifications");
[RCTSharedApplication() registerForRemoteNotifications];
#endif // TARGET_IPHONE_SIMULATOR
Expand All @@ -429,9 +448,10 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu
resolve([NSNull null]);
break;

default:
resolve(@(CLLocationManager.authorizationStatus == kCLAuthorizationStatusAuthorizedAlways));
default: {
resolve(@([self hasLocationPermission]));
break;
}
}
}

Expand All @@ -450,7 +470,8 @@ - (void)manager:(NITManager* _Nonnull)manager alertWantsToShowContent:(id _Nonnu
[locationManager requestAlwaysAuthorization];
} else {
// resolve if user hase given 'Always' permission
resolve(@(CLLocationManager.authorizationStatus == kCLAuthorizationStatusAuthorizedAlways));
BOOL locationPermission = [self hasLocationPermission];
resolve(@(locationPermission));
}
}

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.2.7-beta.6",
"version": "2.2.8-beta.1",
"author": "Mattia Panzeri <[email protected]>",
"license": "MPL-2.0",
"description": "The official NearIT SDK plugin for React Native",
Expand Down
2 changes: 1 addition & 1 deletion sample/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target 'nearsdksample' do
# use_frameworks!

# Pods for nearsdksample
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'yoga', :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'BatchedBridge', # Required For React Native 0.45.0+
'Core',
Expand Down
44 changes: 23 additions & 21 deletions sample/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
PODS:
- NearITSDK (2.2.4)
- React (0.48.1):
- React/Core (= 0.48.1)
- React/BatchedBridge (0.48.1):
- NearITSDK (2.2.5)
- React (0.49.3):
- React/Core (= 0.49.3)
- React/BatchedBridge (0.49.3):
- React/Core
- React/cxxreact_legacy
- React/Core (0.48.1):
- Yoga (= 0.48.1.React)
- React/cxxreact_legacy (0.48.1):
- React/Core (0.49.3):
- yoga (= 0.49.3.React)
- React/cxxreact_legacy (0.49.3):
- React/jschelpers_legacy
- React/DevSupport (0.48.1):
- React/DevSupport (0.49.3):
- React/Core
- React/RCTWebSocket
- React/jschelpers_legacy (0.48.1)
- React/RCTBlob (0.48.1):
- React/fishhook (0.49.3)
- React/jschelpers_legacy (0.49.3)
- React/RCTBlob (0.49.3):
- React/Core
- React/RCTWebSocket (0.48.1):
- React/RCTWebSocket (0.49.3):
- React/Core
- React/fishhook
- React/RCTBlob
- RNNearIt (2.2.7-beta.6):
- NearITSDK (= 2.2.4)
- RNNearIt (2.2.8-beta.1):
- NearITSDK (= 2.2.5)
- React
- Yoga (0.48.1.React)
- yoga (0.49.3.React)

DEPENDENCIES:
- React/BatchedBridge (from `../node_modules/react-native`)
- React/Core (from `../node_modules/react-native`)
- React/DevSupport (from `../node_modules/react-native`)
- RNNearIt (from `../node_modules/react-native-nearit`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
- yoga (from `../node_modules/react-native/ReactCommon/yoga`)

EXTERNAL SOURCES:
React:
:path: ../node_modules/react-native
RNNearIt:
:path: ../node_modules/react-native-nearit
Yoga:
yoga:
:path: ../node_modules/react-native/ReactCommon/yoga

SPEC CHECKSUMS:
NearITSDK: a5eb344a2673db0c59e06a512f84cb2ea1f666c2
React: c409fc3f984bbc91da9328ace90b0851759c8111
RNNearIt: a190fe7aa6c6044257f7c9c107b1433a0a54a54f
Yoga: 1a0ed95233aeb0ed308fc70fabeb4348234a61d5
NearITSDK: 4f6eefd233f8af59682ee9ce2214b1ff32c3da92
React: 5751f5630c58f7ef31a00cf03044878295bceff0
RNNearIt: d3773d67a7e1df7c79e3d314c517c9b9c8cff2df
yoga: 6e56575501ecea04196f9c9f08b90cf97cd5da24

PODFILE CHECKSUM: e0a64d713adf04105d0bcece2008407031091a0e
PODFILE CHECKSUM: c7fa801c9f49a93403e6c7e9c8b9eeeb817ebc52

COCOAPODS: 1.3.1
6 changes: 3 additions & 3 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"test": "node node_modules/jest/bin/jest.js --watch"
},
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.48.1",
"react": "16.0.0-beta.5",
"react-native": "0.49.3",
"react-native-iphone-x-helper": "^1.0.1",
"react-native-nearit": "^2.2.7-beta.6"
"react-native-nearit": "^2.2.8-beta.1"
},
"devDependencies": {
"babel-preset-react-native-stage-0": "^1.0.1",
Expand Down
Loading

0 comments on commit 72d2681

Please sign in to comment.