Skip to content

Commit bc138d2

Browse files
author
queue-it
committed
Preparing release 1.1.3
1 parent 112bbaf commit bc138d2

File tree

25 files changed

+52038
-25807
lines changed

25 files changed

+52038
-25807
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
example
22
.circleci
33
node_modules
4+

README.md

Lines changed: 76 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,98 +5,132 @@
55
React Native Module for integrating Queue-it's virtual waiting room into React Native apps.
66

77
## Sample app
8+
89
A sample app project to try out functionality in the library can be found in the [example](https://github.com/queueit/react-native-queue-it/tree/master/example) directory.
910

1011
## Installation
12+
1113
Before starting please download the whitepaper **Mobile App Integration** from the Go Queue-it Platform. This whitepaper contains the needed information to perform a successful integration.
1214

1315
Using npm you can install the module:
14-
``` sh
16+
17+
```sh
1518
npm install --save react-native-queue-it
1619
#On iOS
1720
cd ios && pod install
1821
```
1922

2023
When Android is used, the following activity also needs to be included in the application's manifest file.
2124

22-
``` xml
25+
```xml
2326
<activity android:name="com.queue_it.androidsdk.QueueActivity"/>
2427
```
2528

2629
## Usage
30+
2731
To protect parts of your application you'll need to make a `QueueIt.run` call and await it's result.
2832
Once the async call completes, the user has gone through the queue and you get a **QueueITToken** for this session.
2933

30-
``` js
31-
import { QueueIt, EnqueueResultState } from 'react-native-queue-it';
34+
```tsx
35+
import {
36+
QueueIt,
37+
EnqueueResultState,
38+
EnqueueResult,
39+
} from 'react-native-queue-it';
3240

3341
// ...
3442

3543
//This function would make the user enter a queue and it would await for his turn to come.
3644
//It returns a QueueITToken that signifies the user's session.
45+
//If you have an enqueue key or token you need to use the matching method call.
3746
//An exception would be thrown if:
3847
// 1) Queue-it's servers can't be reached (connectivity issue).
3948
// 2) SSL connection error if custom queue domain is used having an invalid certificate.
4049
// 3) Client receives HTTP 4xx response.
4150
// In all these cases is most likely a misconfiguration of the queue settings:
4251
// Invalid customer ID, event alias ID or cname setting on queue (GO Queue-it portal -> event settings).
4352
enqueue = async () => {
44-
try {
45-
console.log('going to queue-it');
46-
//We wait for the `openingQueueView` event to be emitted once.
47-
QueueIt.once('openingQueueView', () => {
48-
console.log('opening queue page..');
49-
});
50-
QueueIt.once('userExited', () => {
51-
console.log('user exited the line');
52-
});
53-
//Optional layout name that should be used for the waiting room page
54-
const layoutName = null;
55-
//Optional language for the waiting room page
56-
const language = null;
57-
const enqueueResult = await QueueIt.run(
58-
this.state.customerId,
59-
this.state.waitingRoomIdOrAlias,
60-
layoutName,
61-
language
53+
try {
54+
console.log('going to queue-it');
55+
//We wait for the `openingQueueView` event to be emitted once.
56+
QueueIt.once('openingQueueView', () => {
57+
console.log('opening queue page..');
58+
});
59+
//Optional layout name that should be used for the waiting room page
60+
const layoutName = null;
61+
//Optional language for the waiting room page
62+
const language = null;
63+
let enqueueResult: EnqueueResult;
64+
65+
if (this.state.enqueueKey) {
66+
enqueueResult = await QueueIt.runWithEnqueueKey(
67+
this.state.clientId,
68+
this.state.eventOrAlias,
69+
this.getEnqueueKey(),
70+
'mobile'
71+
);
72+
} else if (this.state.enqueueToken) {
73+
enqueueResult = await QueueIt.runWithEnqueueToken(
74+
this.state.clientId,
75+
this.state.eventOrAlias,
76+
this.getEnqueueToken(),
77+
'mobile'
78+
);
79+
} else {
80+
enqueueResult = await QueueIt.run(
81+
this.state.clientId,
82+
this.state.eventOrAlias,
83+
'mobile'
6284
);
63-
switch (enqueueResult.State) {
64-
case EnqueueResultState.Disabled:
65-
console.log('queue is disabled');
66-
break;
67-
case EnqueueResultState.Passed:
68-
console.log(`user got his turn, with QueueITToken: ${enqueueResult.QueueITToken}`);
69-
break;
70-
case EnqueueResultState.Unavailable:
71-
console.log('queue is unavailable');
72-
break;
73-
}
74-
return enqueueResult.QueueITToken;
75-
} catch (e) {
76-
console.log(`error: ${e}`);
7785
}
86+
switch (enqueueResult.State) {
87+
case EnqueueResultState.Disabled:
88+
console.log('queue is disabled');
89+
break;
90+
case EnqueueResultState.Passed:
91+
console.log(
92+
`user got his turn, with QueueITToken: ${enqueueResult.QueueITToken}`
93+
);
94+
break;
95+
case EnqueueResultState.Unavailable:
96+
console.log('queue is unavailable');
97+
break;
98+
case EnqueueResultState.RestartedSession:
99+
console.log('user decided to restart the session');
100+
await this.enqueue();
101+
}
102+
return enqueueResult.QueueITToken;
103+
} catch (e) {
104+
console.log(`error: ${e}`);
105+
}
78106
};
107+
108+
getEnqueueToken = () => 'myToken';
109+
110+
getEnqueueKey = () => 'myKey';
79111
```
80-
As the App developer you must manage the state (whether user was previously queued up or not) inside your app's storage. After you have awaited the `run` call, the app must remember this, possibly with a date/time expiration. When the user goes to another page/screen - you check his state, and only call `run` in the case where the user was not previously queued up. When the user clicks back, the same check needs to be done.
81112

82-
![App Integration Flow](https://github.com/queueit/react-native-queue-it/blob/master/App%20integration%20flow.PNG "App Integration Flow")
113+
As the App developer you must manage the state (whether user was previously queued up or not) inside your app's storage. After you have awaited the `run` call, the app must remember this, possibly with a date/time expiration. When the user goes to another page/screen - you check his state, and only call `run` in the case where the user was not previously queued up. When the user clicks back, the same check needs to be done.
83114

115+
![App Integration Flow](https://github.com/queueit/react-native-queue-it/blob/master/App%20integration%20flow.PNG 'App Integration Flow')
84116

85117
### Events
86118

87119
You can receive events from this library by subscribing to it:
120+
88121
```js
89-
QueueIt.once('openingQueueView', ()=> console.log('opening queue page..'));
122+
QueueIt.once('openingQueueView', () => console.log('opening queue page..'));
90123
//Or
91-
const listener = QueueIt.on('openingQueueView', ()=> console.log('opening queue page..'));
124+
const listener = QueueIt.on('openingQueueView', () =>
125+
console.log('opening queue page..')
126+
);
92127
// ...
93128
listener.remove();
94129
```
95130

96131
Right now these are the events that are emitted:
97132

98-
* `openingQueueView` - Happens whenever the queue screen is going to be shown.
99-
* `userExited` - Happens whenever the user exists the line. Note that he may return back to it if he desires.
133+
- `openingQueueView` - Happens whenever the queue screen is going to be shown.
100134

101135
## License
102136

android/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ buildscript {
33
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['QueueIt_kotlinVersion']
44

55
repositories {
6+
mavenCentral()
7+
mavenLocal()
68
google()
7-
jcenter()
89
}
910

1011
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.1.1'
12+
classpath 'com.android.tools.build:gradle:4.1.3'
1213
// noinspection DifferentKotlinGradleVersion
1314
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1415
}
@@ -52,7 +53,7 @@ android {
5253

5354
repositories {
5455
mavenCentral()
55-
jcenter()
56+
mavenLocal()
5657
google()
5758

5859
def found = false
@@ -129,7 +130,7 @@ dependencies {
129130
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
130131

131132
//App dependencies
132-
implementation 'com.queue_it.androidsdk:library:2.0.32'
133+
implementation 'com.queue-it.androidsdk:library:2.0.35'
133134
implementation 'com.android.support:appcompat-v7:28.0.0'
134135
implementation 'com.android.support:design:28.0.0'
135136
}

android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
QueueIt_kotlinVersion=1.3.50
1+
QueueIt_kotlinVersion=1.4.10
22
QueueIt_compileSdkVersion=28
33
QueueIt_buildToolsVersion=28.0.3
44
QueueIt_targetSdkVersion=28

android/src/main/java/com/reactnativequeueit/QueueItModule.kt

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.queue_it.androidsdk.*
77

88

99
enum class EnqueueResultState {
10-
Passed, Disabled, Unavailable
10+
Passed, Disabled, Unavailable, RestartedSession
1111
}
1212

1313
class QueueItModule(reactContext: ReactApplicationContext)
@@ -26,8 +26,8 @@ class QueueItModule(reactContext: ReactApplicationContext)
2626
}
2727

2828
@ReactMethod
29-
fun runAsync(customerId: String, eventAlias: String, layoutName: String?, language: String?, promise: Promise) {
30-
val qListener = object : QueueListener() {
29+
fun getQueueListener(promise: Promise): QueueListener {
30+
return object : QueueListener() {
3131
override fun onUserExited() {
3232
val params = Arguments.createMap()
3333
sendEvent(context, "userExited", params)
@@ -36,7 +36,7 @@ class QueueItModule(reactContext: ReactApplicationContext)
3636
override fun onQueuePassed(queuePassedInfo: QueuePassedInfo?) {
3737
handler.post {
3838
val params = Arguments.createMap()
39-
val token = if (queuePassedInfo?.queueItToken!=null) queuePassedInfo.queueItToken else ""
39+
val token = if (queuePassedInfo?.queueItToken != null) queuePassedInfo.queueItToken else ""
4040
params.putString("queueittoken", token)
4141
params.putString("state", EnqueueResultState.Passed.name)
4242
promise.resolve(params)
@@ -71,14 +71,42 @@ class QueueItModule(reactContext: ReactApplicationContext)
7171
promise.reject("error", errorMessage)
7272
}
7373
}
74+
75+
override fun onSessionRestart(queueITEngine: QueueITEngine?) {
76+
handler.post {
77+
val params = Arguments.createMap()
78+
params.putNull("queueittoken")
79+
params.putString("state", EnqueueResultState.RestartedSession.name)
80+
promise.resolve(params)
81+
}
82+
}
7483
}
84+
}
7585

86+
@ReactMethod
87+
fun runAsync(customerId: String, eventAlias: String, layoutName: String?, language: String?, promise: Promise) {
7688
handler.post {
77-
val queueEngine = QueueITEngine(context.currentActivity, customerId, eventAlias, layoutName, language, qListener)
89+
val queueEngine = QueueITEngine(context.currentActivity, customerId, eventAlias, layoutName, language, getQueueListener(promise))
7890
queueEngine.run(context.currentActivity)
7991
}
8092
}
8193

94+
@ReactMethod
95+
fun runWithEnqueueTokenAsync(customerId: String, eventAlias: String, enqueueToken: String, layoutName: String?, language: String?, promise: Promise) {
96+
handler.post {
97+
val queueEngine = QueueITEngine(context.currentActivity, customerId, eventAlias, layoutName, language, getQueueListener(promise))
98+
queueEngine.runWithEnqueueToken(context.currentActivity, enqueueToken)
99+
}
100+
}
101+
102+
@ReactMethod
103+
fun runWithEnqueueKeyAsync(customerId: String, eventAlias: String, enqueueKey: String, layoutName: String?, language: String?, promise: Promise) {
104+
handler.post {
105+
val queueEngine = QueueITEngine(context.currentActivity, customerId, eventAlias, layoutName, language, getQueueListener(promise))
106+
queueEngine.runWithEnqueueKey(context.currentActivity, enqueueKey)
107+
}
108+
}
109+
82110
private fun sendEvent(reactContext: ReactContext,
83111
eventName: String,
84112
params: WritableMap) {
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.reactnativequeueit
22

33
import java.util.Arrays
4-
import java.util.Collections
54

65
import com.facebook.react.ReactPackage
76
import com.facebook.react.bridge.NativeModule
87
import com.facebook.react.bridge.ReactApplicationContext
98
import com.facebook.react.uimanager.ViewManager
10-
import com.facebook.react.bridge.JavaScriptModule
11-
import com.facebook.react.bridge.ReactMethod
129

1310
class QueueItPackage : ReactPackage {
1411
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
@@ -18,5 +15,4 @@ class QueueItPackage : ReactPackage {
1815
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
1916
return emptyList<ViewManager<*, *>>()
2017
}
21-
2218
}

example/ios/Podfile

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,23 @@
1-
platform :ios, '11.4'
1+
platform :ios, '11.0'
2+
require_relative '../node_modules/react-native/scripts/react_native_pods'
23
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
34

4-
def add_flipper_pods!
5-
version = '~> 0.33.1'
6-
pod 'FlipperKit', version, :configuration => 'Debug'
7-
pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
8-
pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
9-
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
10-
pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
11-
end
12-
# Post Install processing for Flipper
13-
def flipper_post_install(installer)
14-
installer.pods_project.targets.each do |target|
15-
if target.name == 'YogaKit'
16-
target.build_configurations.each do |config|
17-
config.build_settings['SWIFT_VERSION'] = '4.1'
18-
end
19-
end
20-
end
21-
end
22-
235
target 'QueueItExample' do
24-
# Pods for QueueItExample
25-
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
26-
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
27-
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
28-
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
29-
pod 'React', :path => '../node_modules/react-native/'
30-
pod 'React-Core', :path => '../node_modules/react-native/'
31-
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
32-
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
33-
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
34-
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
35-
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
36-
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
37-
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
38-
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
39-
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
40-
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
41-
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
42-
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
43-
44-
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
45-
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
46-
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
47-
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
48-
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
49-
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
50-
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
51-
52-
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
53-
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
54-
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
6+
config = use_native_modules!
7+
use_react_native!(
8+
:path => config[:reactNativePath],
9+
# to enable hermes on iOS, change `false` to `true` and then install pods
10+
:hermes_enabled => false
11+
)
5512

5613
pod 'react-native-queue-it', :path => '../..'
14+
# you should disable the next line.
15+
# use_flipper!()
5716

58-
use_native_modules!
59-
60-
# Enables Flipper.
61-
#
62-
# Note that if you have use_frameworks! enabled, Flipper will not work and
63-
# you should disable these next few lines.
64-
add_flipper_pods!
6517
pod 'RNCCheckbox', :path => '../node_modules/@react-native-community/checkbox'
6618

6719
post_install do |installer|
68-
flipper_post_install(installer)
20+
react_native_post_install(installer)
21+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
6922
end
7023
end

0 commit comments

Comments
 (0)