react-native-pointr 8.14.0 → 8.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [8.14.1]
8
+
9
+ ### Added
10
+ - `showMapWidget` method to modify `PTRMapWidget` UI component.
11
+ - `PTRCommand` type has been added to modify `PTRMapWidget`.
12
+ - `PTRMapWidget` UI component.
13
+ - `shouldRequestPermissionsAtStartup` method has been added.
14
+ - `requestPermissions` method has been added.
15
+
16
+ ### Changed
17
+ - Shows pop up dialog when map fails to load for Android.
18
+
19
+ ### Fixed
20
+ - Fix unable to show path between pois on initial run.
21
+ - Fix cases when there is a problem with loading the map.
22
+
23
+ ### Deprecated
24
+ - None.
25
+
26
+ ### Removed
27
+ - None.
28
+
29
+ ### Security
30
+ - None.
package/README.md CHANGED
@@ -1,3 +1,306 @@
1
- # react-native-pointr
2
- Public repository for Pointr Mobile SDK React-Native Package
3
- https://npmjs.org/pointrlabs/react-native-pointr
1
+ # Installation Guide for react-native-pointr NPM Package
2
+
3
+ This guide will walk you through the steps to install and configure the `react-native-pointr` npm package for your React Native project.
4
+
5
+ ## Prerequisites
6
+
7
+ Ensure you have the following set up before proceeding:
8
+
9
+ - Node.js installed (v18 or above).
10
+ - React Native CLI or Expo CLI installed.
11
+ - A React Native project already set up.
12
+
13
+ ## 1. Install the Package
14
+
15
+ Run the following command to install the package using npm:
16
+
17
+ ```
18
+ npm i react-native-pointr
19
+ ```
20
+
21
+ Or, if you use Yarn:
22
+
23
+ ```
24
+ yarn add react-native-pointr
25
+ ```
26
+
27
+ ## 2. Integration to Mobile Platforms
28
+
29
+ === "iOS"
30
+
31
+ For iOS projects, make sure to install the CocoaPods dependencies:
32
+
33
+ Navigate to the iOS folder:
34
+
35
+ ```
36
+ cd ios
37
+ ```
38
+
39
+ Open the `Podfile` with a text editor and add the access token and source for `PointrKit.xcframework` to the top of the file
40
+
41
+ ```
42
+ source "https://github.com/pointrlabs/public-podspecs.git"
43
+ ENV['POINTR_SDK_TOKEN'] = '<YOUR_TOKEN>'
44
+ ```
45
+
46
+ !!! note
47
+
48
+ Acquire token (`<YOUR_TOKEN>`) to download the package and Pointr iOS native library from Pointr representative.
49
+
50
+ Run the following command to install the Pods:
51
+ ```
52
+ pod install
53
+ ```
54
+
55
+ !!! warning
56
+
57
+ - If you encounter an issue similar to the following:
58
+ ```
59
+ [!] Unable to find a specification for `SocketRocket (= 0.7.0)` depended upon by `React-Core`
60
+ You have either:
61
+ * mistyped the name or version.
62
+ * not added the source repo that hosts the Podspec to your Podfile.
63
+ ```
64
+ - Next, add the following line within your target block.
65
+ ```
66
+ pod 'SocketRocket', :git => 'https://github.com/facebookincubator/SocketRocket.git', :tag => '0.7.0'
67
+ ```
68
+ For example, if your project name is "TestProject", your target 'TestProject' should look like this:
69
+ ```
70
+ target 'TestProject' do
71
+ config = use_native_modules!
72
+ pod 'SocketRocket', :git => 'https://github.com/facebookincubator/SocketRocket.git', :tag => '0.7.0'
73
+ use_react_native!(
74
+ :path => config[:reactNativePath],
75
+ # An absolute path to your application root.
76
+ :app_path => "#{Pod::Config.instance.installation_root}/.."
77
+ )
78
+ ...
79
+ ```
80
+
81
+
82
+ Return to the root project directory:
83
+
84
+ ```
85
+ cd ..
86
+ ```
87
+
88
+ === "Android"
89
+
90
+ For Android projects, make sure you add the repository to get Pointr Android native libraries.
91
+
92
+ Navigate to the Android folder:
93
+
94
+ ```
95
+ cd android
96
+ ```
97
+
98
+ Open `build.gradle` with an editor and add the following lines.
99
+
100
+ ```
101
+ allprojects {
102
+ repositories {
103
+ maven {
104
+ url "https://android.pointr.dev/artifactory/gradle-release-local"
105
+ credentials {
106
+ username '<USERNAME>'
107
+ password '<PASSWORD>'
108
+ }
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ !!! note
115
+
116
+ Acquire user name (`<USERNAME>`) and password (`<PASSWORD>`) to access the repository that hosts Pointr Android native library from Pointr representative.
117
+
118
+ Return to the root project directory:
119
+
120
+ ```
121
+ cd ..
122
+ ```
123
+
124
+ Make sure your Android project is set up to use AndroidX (React Native 0.60 and above support AndroidX out of the box). No additional steps should be necessary. If you encounter any issues, ensure your android/build.gradle is using the correct dependencies.
125
+
126
+ ## 4. Usage
127
+
128
+ Now you can start using the package in your React Native components. Here's a simple example of how to import on `App.tsx` file:
129
+
130
+ ```typescript
131
+ ...
132
+ import React, { useEffect, useRef } from 'react';
133
+ import {
134
+ requireNativeComponent,
135
+ UIManager,
136
+ findNodeHandle,
137
+ Button,
138
+ SafeAreaView,
139
+ View,
140
+ ScrollView,
141
+ Dimensions,
142
+ StyleSheet,
143
+ NativeModules
144
+ } from 'react-native';
145
+ import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType } from 'react-native-pointr/src/PTRCommand';
146
+ import { showMapWidget } from 'react-native-pointr/src/PTRMapWidgetUtils';
147
+ ```
148
+
149
+ Initialize and start Pointr instance before doing any operation.
150
+
151
+ ```typescript
152
+
153
+ // initialize Pointr instance with the provided credentials
154
+ NativeModules.PTRNativePointrLibrary.initialize("<LICENSE_KEY>", "<API_URL>", "<CLIEND_ID>", "<ENVIRONMENT>", <LOG_LEVEL>);
155
+ NativeModules.PTRNativePointrLibrary.start((state: string) => {
156
+ console.log(`Pointr state: ${state}`);
157
+ });
158
+ ```
159
+
160
+ Define the `PTRMapWidget` component using `requireNativeComponent`:
161
+
162
+ ```typescript
163
+ interface PTRMapWidgetProps {
164
+ onMapDidEndLoading?: (event: NativeSyntheticEvent<object>) => void;
165
+ }
166
+
167
+ export const PTRMapWidget = requireNativeComponent<PTRMapWidgetProps>('PTRMapWidget');
168
+ ```
169
+
170
+ Implement the map widget in your React Native component:
171
+
172
+ ```typescript
173
+ function App(): React.JSX.Element {
174
+
175
+ const ref = useRef(null);
176
+
177
+ const handleMapWidgetDidEndLoading = (event: NativeSyntheticEvent<object>) => {
178
+ const ptrCommand = event.nativeEvent;
179
+ if (ptrCommand.command == "site") {
180
+ console.log("Map did end loading with parameters:", ptrCommand.command, ptrCommand.siteExternalIdentifier, ptrCommand.error);
181
+ } else if (ptrCommand.command == "building") {
182
+ console.log("Map did end loading with parameters:", ptrCommand.command, ptrCommand.siteExternalIdentifier, ptrCommand.buildingExternalIdentifier, ptrCommand.error);
183
+ } else if (ptrCommand.command == "level") {
184
+ console.log("Map did end loading with parameters:", ptrCommand.command, ptrCommand.siteExternalIdentifier, ptrCommand.buildingExternalIdentifier, ptrCommand.levelIndex, ptrCommand.error);
185
+ } else if (ptrCommand.command == "poi") {
186
+ console.log("Map did end loading with parameters:", ptrCommand.command, ptrCommand.siteExternalIdentifier, ptrCommand.poiExternalIdentifier, ptrCommand.error);
187
+ } else if (ptrCommand.command == "path") {
188
+ console.log("Map did end loading with parameters:", ptrCommand.command, ptrCommand.siteExternalIdentifier, ptrCommand.poiExternalIdentifier, ptrCommand.error);
189
+ } else if (ptrCommand.command == "staticPath") {
190
+ console.log("Map did end loading with parameters:", ptrCommand.command, ptrCommand.siteExternalIdentifier, ptrCommand.fromPoiExternalIdentifier, ptrCommand.toPoiExternalIdentifier, ptrCommand.error);
191
+ } else {
192
+ console.log("Map did end loading with unknown parameters:", ptrCommand);
193
+ }
194
+ };
195
+
196
+ return (
197
+ <SafeAreaView style={{ flex: 1 }}>
198
+ <ScrollView contentInsetAdjustmentBehavior="automatic" style={{ flex: 1 }}>
199
+ <Button
200
+ title="Show Site"
201
+ onPress={() => {
202
+ const reactTag = findNodeHandle(ref.current);
203
+ console.log(`React tag: "${reactTag}" to show site`);
204
+ if (reactTag !== null) {
205
+ let command = new PTRSiteCommand("officebuilding");
206
+ showMapWidget(reactTag, command);
207
+ } else {
208
+ console.error("Failed to find node handle for ref");
209
+ }
210
+ }}
211
+ />
212
+ <Button
213
+ title="Show Building"
214
+ onPress={() => {
215
+ const reactTag = findNodeHandle(ref.current);
216
+ console.log(`React tag: "${reactTag}" to show building`);
217
+ if (reactTag !== null) {
218
+ let command = new PTRBuildingCommand("officebuilding", "office2");
219
+ showMapWidget(reactTag, command);
220
+ } else {
221
+ console.error("Failed to find node handle for ref");
222
+ }
223
+ }}
224
+ />
225
+ <Button
226
+ title="Show level"
227
+ onPress={() => {
228
+ const reactTag = findNodeHandle(ref.current);
229
+ console.log(`React tag: "${reactTag}" to show level`);
230
+ if (reactTag !== null) {
231
+ let command = new PTRLevelCommand("officebuilding", "office2", 2);
232
+ showMapWidget(reactTag, command);
233
+ } else {
234
+ console.error("Failed to find node handle for ref");
235
+ }
236
+ }}
237
+ />
238
+ <Button
239
+ title="Show Poi"
240
+ onPress={() => {
241
+ const reactTag = findNodeHandle(ref.current);
242
+ console.log(`React tag: "${reactTag}" to show poi`);
243
+ if (reactTag !== null) {
244
+ let command = new PTRPoiCommand("officebuilding", "Accessories");
245
+ showMapWidget(reactTag, command);
246
+ } else {
247
+ console.error("Failed to find node handle for ref");
248
+ }
249
+ }}
250
+ />
251
+ <Button
252
+ title="Show path"
253
+ onPress={() => {
254
+ const reactTag = findNodeHandle(ref.current);
255
+ console.log(`React tag: "${reactTag}" to show poi`);
256
+ if (reactTag !== null) {
257
+ let command = new PTRPathCommand("officebuilding", "Accessories");
258
+ showMapWidget(reactTag, command);
259
+ } else {
260
+ console.error("Failed to find node handle for ref");
261
+ }
262
+ }}
263
+ />
264
+ <Button
265
+ title="Show Static Path"
266
+ onPress={() => {
267
+ const reactTag = findNodeHandle(ref.current);
268
+ console.log(`React tag: "${reactTag}" to show site`);
269
+ if (reactTag !== null) {
270
+ let command = new PTRStaticPathCommand("officebuilding", "Accessories", "Lobby");
271
+ showMapWidget(reactTag, command);
272
+ } else {
273
+ console.error("Failed to find node handle for ref");
274
+ }
275
+ }}
276
+ />
277
+ </ScrollView>
278
+ <View style={{ flex: 5 }}>
279
+ <PTRMapWidget ref={ref} style={{ flex: 1 }} onMapWidgetDidEndLoading={handleMapWidgetDidEndLoading} />
280
+ </View>
281
+ </SafeAreaView>
282
+ );
283
+ }
284
+
285
+ export default App;
286
+ ```
287
+
288
+ For more information about the available functionality, check the [API documentation](https://docs.pointr.tech/docs/8.x/Developer%20Portal/API%20Reference/api%20ref-mobile/).
289
+
290
+ ## 5. Run the App
291
+
292
+ After completing the setup, start your app by running:
293
+
294
+ === "iOS"
295
+
296
+ ```
297
+ npx react-native run-ios
298
+ ```
299
+
300
+ === "Android"
301
+
302
+ ```
303
+ npx react-native run-android
304
+ ```
305
+
306
+ That’s it! Your package should now be installed and ready to use in your React Native project. For more details on usage and advanced configuration, refer to the [API documentation](https://docs.pointr.tech/docs/8.x/Developer%20Portal/API%20Reference/api%20ref-mobile/).
@@ -95,8 +95,8 @@ dependencies {
95
95
  //noinspection GradleDynamicVersion
96
96
  implementation "com.facebook.react:react-native:+"
97
97
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98
- implementation "com.pointrlabs:pointr:8.13.0"
99
- implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
98
+ implementation "com.pointrlabs:pointr:8+"
99
+ implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
100
100
  implementation 'androidx.appcompat:appcompat:1.7.0'
101
101
  implementation 'com.google.android.material:material:1.12.0'
102
102
  implementation 'androidx.activity:activity:1.9.1'
@@ -1,5 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="com.pointr">
3
4
  <application>
4
5
  <activity
5
6
  android:name="com.pointr.PointrMapWidgetActivity"
@@ -0,0 +1,17 @@
1
+ package com.pointr
2
+
3
+ import androidx.annotation.StringDef
4
+
5
+
6
+ @Retention(AnnotationRetention.BINARY)
7
+ @StringDef(value = [PTRMapWidgetCommandType.SITE, PTRMapWidgetCommandType.BUILDING, PTRMapWidgetCommandType.LEVEL, PTRMapWidgetCommandType.POI, PTRMapWidgetCommandType.PATH, PTRMapWidgetCommandType.STATIC_PATH])
8
+ annotation class PTRMapWidgetCommandType {
9
+ companion object {
10
+ const val SITE = "site"
11
+ const val BUILDING = "building"
12
+ const val LEVEL = "level"
13
+ const val POI = "poi"
14
+ const val PATH = "path"
15
+ const val STATIC_PATH = "staticPath"
16
+ }
17
+ }