@infilectorg/infiviz-shots-react-sdk 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -6,4 +6,7 @@ Following are the versions for **React Native SDK**
6
6
 
7
7
  - **V 1.0.0** <br/>
8
8
  1. [RN SDK Wrapper Phase 1](https://infilect.atlassian.net/browse/ISS-4810)
9
- Completed RN Wrapper Phase 1
9
+ Completed RN Wrapper Phase 1
10
+
11
+ 2. [Adding broadcast receiver functionality in React Native SDK For Android](https://infilect.atlassian.net/browse/ISS-4865)
12
+ Added broadcast receiver for android
@@ -1,20 +1,10 @@
1
1
  package com.infilect.infivizshotsreactsdk
2
2
 
3
- import android.Manifest
4
- import android.R.id.message
5
3
  import android.app.Activity
6
- import android.app.NotificationChannel
7
- import android.app.NotificationManager
8
- import android.app.PendingIntent
9
4
  import android.content.BroadcastReceiver
10
5
  import android.content.Context
11
6
  import android.content.Intent
12
7
  import android.content.IntentFilter
13
- import android.content.pm.PackageManager
14
- import android.os.Build
15
- import androidx.core.app.ActivityCompat
16
- import androidx.core.app.NotificationCompat
17
- import androidx.core.app.NotificationManagerCompat
18
8
  import androidx.localbroadcastmanager.content.LocalBroadcastManager
19
9
  import com.facebook.react.bridge.ActivityEventListener
20
10
  import com.facebook.react.bridge.Arguments
@@ -28,7 +18,6 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
28
18
  import com.google.gson.Gson
29
19
  import com.infilect.actions.ACTION_TYPE
30
20
  import com.infilect.actions.IRResultAndActionsCallback
31
- import com.infilect.infivizshotsreactsdk.InfivizShotsReactSdkModule
32
21
  import infilect.infiviz.InfiVizShotsSDK
33
22
  import infilect.infiviz.IntentConstants
34
23
  import infilect.infiviz.error.ErrorEnums
@@ -41,7 +30,6 @@ import infilect.infiviz.infilect_client.model.ivyresponse.InfiSession
41
30
  import infilect.infiviz.infilect_client.model.ivyresponse.SDKCallback
42
31
  import infilect.infiviz.infilect_client.model.ivyresponse.UploadCallback
43
32
  import infilect.infiviz.sdkEnvironment.InfivizshotsEnvironment
44
- import okhttp3.internal.notify
45
33
  import kotlin.jvm.java
46
34
 
47
35
  @ReactModule(name = InfivizShotsReactSdkModule.NAME)
@@ -54,59 +42,6 @@ class InfivizShotsReactSdkModule(private val reactContext: ReactApplicationConte
54
42
 
55
43
  private lateinit var irResultCallback: IRResultAndActionsCallback
56
44
 
57
- private fun showCustomNotification(context: Context, sessionId: String) {
58
- val channelId = "real_time_results_channel"
59
- val name = "Real Time Results"
60
- val descriptionText = "Notifications for real-time result updates"
61
-
62
- // Step 1: Create the channel (required for Android 8+)
63
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
64
- val importance = NotificationManager.IMPORTANCE_HIGH
65
- val channel = NotificationChannel(channelId, name, importance).apply {
66
- description = descriptionText
67
- }
68
-
69
- val notificationManager: NotificationManager =
70
- context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
71
- notificationManager.createNotificationChannel(channel)
72
- }
73
-
74
-
75
- val builder = NotificationCompat.Builder(context, channelId)
76
- .setSmallIcon(infilect.infiviz.R.drawable.infiviz)
77
- .setContentTitle("Real-Time Results Received. Click To View!")
78
- .setStyle(NotificationCompat.BigTextStyle().bigText("$sessionId is processed!"))
79
- .setPriority(NotificationCompat.PRIORITY_HIGH)
80
-
81
- // Step 4: Show the notification
82
- with(NotificationManagerCompat.from(context)) {
83
- if (ActivityCompat.checkSelfPermission(
84
- reactContext,
85
- Manifest.permission.POST_NOTIFICATIONS
86
- ) != PackageManager.PERMISSION_GRANTED
87
- ) { return }
88
- notify(2001, builder.build())
89
- }
90
- }
91
-
92
- fun createNotificationChannel(context: Context) {
93
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
94
- val name = "MyChannel"
95
- val descriptionText = "Channel for general notifications"
96
- val importance = NotificationManager.IMPORTANCE_DEFAULT
97
- val channel = NotificationChannel("CHANNEL_ID", name, importance).apply {
98
- description = descriptionText
99
- }
100
- val notificationManager: NotificationManager =
101
- context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
102
- notificationManager.createNotificationChannel(channel)
103
- }
104
- }
105
-
106
- private fun sendNotificationForResult() {
107
-
108
- }
109
-
110
45
  private val syncCallbackBroadcast = object : BroadcastReceiver() {
111
46
  override fun onReceive(context: Context?, intent: Intent?) {
112
47
  val status = intent!!.getStringExtra(IntentConstants.STATUS)
@@ -139,6 +74,18 @@ class InfivizShotsReactSdkModule(private val reactContext: ReactApplicationConte
139
74
  }
140
75
  }
141
76
 
77
+ private fun sendSessionRealTimeResultEvent(sessionId: String, message: String, sdkEvent: SDKEvent) {
78
+ val params = Arguments.createMap().apply {
79
+ putString("sessionId", sessionId)
80
+ putString("message", message)
81
+ }
82
+
83
+ if (reactContext.hasActiveReactInstance()) {
84
+ reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
85
+ .emit(sdkEvent.name, params)
86
+ }
87
+ }
88
+
142
89
  override fun getName(): String {
143
90
  return NAME
144
91
  }
@@ -470,9 +417,16 @@ class InfivizShotsReactSdkModule(private val reactContext: ReactApplicationConte
470
417
  broadCastFor: ACTION_TYPE,
471
418
  message: String
472
419
  ) {
473
- showCustomNotification(reactContext, globalSessionId)
474
- }
420
+ when(broadCastFor) {
421
+ ACTION_TYPE.ACTION_GENERATED -> {
422
+ sendSessionRealTimeResultEvent(globalSessionId, message, SDKEvent.ACTION_GENERATED_EVENT)
423
+ }
424
+ ACTION_TYPE.RESULTS_GENERATED -> {
425
+ sendSessionRealTimeResultEvent(globalSessionId, message, SDKEvent.SESSION_RESULT_EVENT)
426
+ }
427
+ }
475
428
 
429
+ }
476
430
  }
477
431
  InfiVizShotsSDK.setIRResultAndActionsCallback(irResultCallback)
478
432
  }
@@ -2,8 +2,8 @@ package com.infilect.infivizshotsreactsdk
2
2
 
3
3
 
4
4
  sealed class SDKEvent(val name: String) {
5
-
6
5
  object SYNC_EVENT : SDKEvent("SyncEvent")
7
- object RESULT_EVENT: SDKEvent("ResultEvent")
6
+ object SESSION_RESULT_EVENT: SDKEvent("SessionRealTimeResultEvent")
8
7
  object CAMERA_EVENT: SDKEvent("CameraEvent")
8
+ object ACTION_GENERATED_EVENT: SDKEvent("ActionsGeneratedEvent")
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infilectorg/infiviz-shots-react-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "React Native package for native libraries",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",