diff --git a/.circleci/config.yml b/.circleci/config.yml index ccadafb0..3053f225 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,10 +32,9 @@ jobs: steps: - checkout: path: ~/react-native-radar - - run: yarn install - - run: sudo yarn global add react-native - - run: chown -R $USER:$USER android - - run: cd android && ./gradlew assembleDebug + - run: cd ../ && npm install && npm run pack && cd example + - run: npm install ../react-native-radar-*.tgz && npm install + - run: cd android && ./gradlew ios: macos: xcode: "13.4.1" @@ -43,10 +42,10 @@ jobs: steps: - checkout: path: ~/react-native-radar - - run: yarn install - - run: sudo yarn global add react-native-cli @react-native-community/cli@11.3.10 + - run: cd ../ && npm install && npm run pack && cd example + - run: npm install ../react-native-radar-*.tgz && npm install - run: cd ios && pod update RadarSDK && pod install - - run: react-native run-ios + - run: xcodebuild -workspace ios/Example.xcworkspace -scheme example -sdk iphonesimulator workflows: version: 2 node-android-ios: diff --git a/.gitignore b/.gitignore index 949fee6f..bf347910 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,4 @@ ios/Carthage/Checkouts ios/Carthage/Build junit.xml dist/ - -example2 react-native-radar-*.tgz diff --git a/android/build.gradle b/android/build.gradle index 3adf63ef..cae363c9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -45,6 +45,6 @@ repositories { dependencies { api 'com.facebook.react:react-native:+' - api 'io.radar:sdk:3.13.0' + api 'io.radar:sdk:3.13.2' } diff --git a/android/src/main/java/io/radar/react/RNRadarModule.java b/android/src/main/java/io/radar/react/RNRadarModule.java index 5ab11209..05b6484b 100644 --- a/android/src/main/java/io/radar/react/RNRadarModule.java +++ b/android/src/main/java/io/radar/react/RNRadarModule.java @@ -97,7 +97,7 @@ public void initialize(String publishableKey, boolean fraud) { this.fraud = fraud; SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit(); editor.putString("x_platform_sdk_type", "ReactNative"); - editor.putString("x_platform_sdk_version", "3.12.1"); + editor.putString("x_platform_sdk_version", "3.12.2"); editor.apply(); if (fraud) { Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud); diff --git a/example/.eslintignore b/example/.eslintignore new file mode 100644 index 00000000..3b497f12 --- /dev/null +++ b/example/.eslintignore @@ -0,0 +1,10 @@ + +@@ -0,0 +1,8 @@ +/node_modules/ +/stories/ +/icons/ +/logos/ +/.next/ +/static/ +/public/ +**/*.bundle.js \ No newline at end of file diff --git a/example/.eslintrc b/example/.eslintrc new file mode 100644 index 00000000..66385364 --- /dev/null +++ b/example/.eslintrc @@ -0,0 +1,46 @@ +{ + "root": true, + + "env": { + "es2021": true, + "node": true, + "react-native/react-native": true + }, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint", + "react", + "react-native" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "airbnb", + "airbnb/hooks" + ], + "rules": { + "no-console": 1, // Means warning + // allow .js files to contain JSX code + "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx",".ts", ".tsx"] }], + + // prevent eslint to complain about the "styles" variable being used before it was defined + "no-use-before-define": ["error", { "variables": false }], + + // ignore errors for the react-navigation package + "react/prop-types": ["error", {"ignore": ["navigation", "navigation.navigate"]}], + + // ignore errors for import directives + "import/extensions": [ + "error", + "ignorePackages", + { + "js": "never", + "jsx": "never", + "ts": "never", + "tsx": "never" + } + ] + + } + } \ No newline at end of file diff --git a/example/.expo-shared/assets.json b/example/.expo-shared/assets.json deleted file mode 100644 index 1e6decfb..00000000 --- a/example/.expo-shared/assets.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true, - "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true -} diff --git a/example/.gitattributes b/example/.gitattributes new file mode 100644 index 00000000..d42ff183 --- /dev/null +++ b/example/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/example/.gitignore b/example/.gitignore index fef5afea..05647d55 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,74 +1,35 @@ -node_modules/**/* -.expo/* -npm-debug.* +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ + +# Native +*.orig.* *.jks *.p8 *.p12 *.key *.mobileprovision -*.orig.* -web-build/ -# macOS -.DS_Store +# Metro +.metro-health-check* -# @generated expo-cli sync-e7dcf75f4e856f7b6f3239b3f3a7dd614ee755a8 -# The following patterns were generated by expo-cli +# debug +npm-debug.* +yarn-debug.* +yarn-error.* -# OSX -# +# macOS .DS_Store +*.pem -# Xcode -# -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate -project.xcworkspace - -# Android/IntelliJ -# -build/ -.idea -.gradle -local.properties -*.iml -*.hprof - -# node.js -# -node_modules/ -npm-debug.log -yarn-error.log - -# BUCK -buck-out/ -\.buckd/ -*.keystore -!debug.keystore - -# Bundle artifacts -*.jsbundle - -# CocoaPods -/ios/Pods/ - -# Expo -.expo/ -web-build/ -dist/ +# local env files +.env*.local -# @end expo-cli \ No newline at end of file +# typescript +*.tsbuildinfo diff --git a/example/.prettierrc b/example/.prettierrc new file mode 100644 index 00000000..d86b77f8 --- /dev/null +++ b/example/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "arrowParens": "always", + "trailingComma": "es5" + } \ No newline at end of file diff --git a/example/App.js b/example/App.tsx similarity index 79% rename from example/App.js rename to example/App.tsx index d661509b..e12796db 100644 --- a/example/App.js +++ b/example/App.tsx @@ -1,45 +1,21 @@ -import React, { useState, useEffect } from "react"; -import { StyleSheet, Text, View, ScrollView } from "react-native"; -import Radar, { Map, Autocomplete, presetEfficient } from "react-native-radar"; -import MapLibreGL from "@maplibre/maplibre-react-native"; -import ExampleButton from "./components/exampleButton"; -MapLibreGL.setAccessToken(null); - -const stringify = (obj) => JSON.stringify(obj, null, 2); - -Radar.on("events", (result) => { - console.log("events:", stringify(result)); -}); - -Radar.on("location", (result) => { - console.log("location:", stringify(result)); -}); - -Radar.on("clientLocation", (result) => { - console.log("clientLocation:", stringify(result)); -}); - -Radar.on("error", (err) => { - console.log("error:", stringify(err)); -}); - -Radar.on("log", (result) => { - console.log("log:", stringify(result)); -}); +import React from 'react'; +import Radar from 'react-native-radar'; +import { useEffect, useState } from 'react'; +import { StyleSheet, Text, View, ScrollView, Button } from "react-native"; export default function App() { // add in your test code here! const [displayText, setDisplayText] = useState(""); - const handlePopulateText = (displayText) => { + const handlePopulateText = (displayText: any) => { setDisplayText(displayText); }; - const stringify = (obj) => JSON.stringify(obj, null, 2); + const stringify = (obj: any) => JSON.stringify(obj, null, 2); useEffect(() => { Radar.initialize( - "prj_test_pk_0000000000000000000000000000000000000000", + "prj_test_pk_333df0ef19f87a254f12cb1818de8443181054a7", true ); @@ -59,24 +35,24 @@ export default function App() { return ( - + {/* */} - + /> */} {displayText} - { Radar.getUserId() @@ -88,7 +64,7 @@ export default function App() { }); }} /> - { Radar.getDescription() @@ -100,7 +76,7 @@ export default function App() { }); }} /> - { Radar.getMetadata() @@ -112,7 +88,7 @@ export default function App() { }); }} /> - { Radar.requestPermissions(false) @@ -124,7 +100,7 @@ export default function App() { }); }} /> - { Radar.getPermissionsStatus() @@ -136,7 +112,7 @@ export default function App() { }); }} /> - { Radar.getLocation() @@ -148,7 +124,7 @@ export default function App() { }); }} /> - { Radar.trackOnce() @@ -160,8 +136,19 @@ export default function App() { }); }} /> - - { + Radar.isTracking() + .then((result) => { + handlePopulateText("isTracking:" + result); + }) + .catch((err) => { + handlePopulateText("isTracking:" + err); + }); + }} + /> +