Skip to content

Commit b44ed40

Browse files
author
sozinov
committed
WMSDK-445: update example
1 parent 4458814 commit b44ed40

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

example/exampleApp/android/app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@
4545
<meta-data
4646
android:name="ru.rustore.sdk.pushclient.project_id"
4747
android:value="l3JnmQZv0CdlZ39y9VERUA8c-P2ys1Ud" />
48+
49+
<meta-data
50+
android:name="com.mindbox.sdk.AUTO_INIT_ENABLED"
51+
android:value="false" />
4852
</application>
4953
</manifest>

example/exampleApp/android/app/src/main/java/com/exampleapp/MainActivity.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import com.facebook.react.defaults.DefaultReactActivityDelegate
1313
import com.mindboxsdk.MindboxJsDelivery
1414

1515
class MainActivity : ReactActivity() {
16-
private var mJsDelivery: MindboxJsDelivery? = null
16+
private var jsDelivery: MindboxJsDelivery? = null
1717
override fun getMainComponentName(): String = "exampleApp"
1818

1919
override fun createReactActivityDelegate(): ReactActivityDelegate =
@@ -22,7 +22,7 @@ class MainActivity : ReactActivity() {
2222
// Initializes MindboxJsDelivery and sends the current intent to React Native
2323
// https://developers.mindbox.ru/docs/flutter-push-navigation-react-native
2424
private fun initializeAndSentIntent(context: ReactContext) {
25-
mJsDelivery = MindboxJsDelivery.Shared.getInstance(context)
25+
jsDelivery = MindboxJsDelivery.Shared.getInstance(context)
2626
if (context.hasCurrentActivity()) {
2727
sendIntent(context, context.getCurrentActivity()!!.getIntent())
2828
} else {
@@ -32,20 +32,20 @@ class MainActivity : ReactActivity() {
3232

3333
override fun onCreate(savedInstanceState: Bundle?) {
3434
super.onCreate(savedInstanceState)
35-
val mReactInstanceManager = getReactNativeHost().getReactInstanceManager();
36-
val reactContext = mReactInstanceManager.getCurrentReactContext();
35+
val reactInstanceManager = getReactNativeHost().getReactInstanceManager();
36+
val reactContext = reactInstanceManager.getCurrentReactContext();
3737

3838
// Initialize and send intent if React context is already available
3939
// https://developers.mindbox.ru/docs/flutter-push-navigation-react-native
4040
if (reactContext != null) {
4141
initializeAndSentIntent(reactContext);
4242
} else {
4343
// Add listener to initialize and send intent once React context is initialized
44-
mReactInstanceManager.addReactInstanceEventListener(object :
44+
reactInstanceManager.addReactInstanceEventListener(object :
4545
ReactInstanceManager.ReactInstanceEventListener {
4646
override fun onReactContextInitialized(context: ReactContext) {
4747
initializeAndSentIntent(context)
48-
mReactInstanceManager.removeReactInstanceEventListener(this)
48+
reactInstanceManager.removeReactInstanceEventListener(this)
4949
}
5050
})
5151
}
@@ -63,6 +63,6 @@ class MainActivity : ReactActivity() {
6363
Mindbox.onNewIntent(intent)
6464
//send click action
6565
Mindbox.onPushClicked(context, intent)
66-
mJsDelivery?.sendPushClicked(intent);
66+
jsDelivery?.sendPushClicked(intent);
6767
}
6868
}

example/exampleApp/android/app/src/main/java/com/exampleapp/MainApplication.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
2121
import com.google.gson.Gson
2222
import com.google.gson.reflect.TypeToken
2323
import cloud.mindbox.mindbox_rustore.MindboxRuStore
24+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
25+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
26+
import com.facebook.react.defaults.DefaultReactNativeHost
2427

2528
class MainApplication : Application(), ReactApplication {
2629

@@ -39,6 +42,10 @@ class MainApplication : Application(), ReactApplication {
3942
//The fifth step of https://developers.mindbox.ru/docs/firebase-send-push-notifications-react-native
4043
Mindbox.initPushServices(this, listOf(MindboxFirebase, MindboxHuawei, MindboxRuStore))
4144
SoLoader.init(this, false)
45+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
46+
// If you opted-in for the New Architecture, we load the native entry point for this app.
47+
load()
48+
}
4249
}
4350

4451
private val gson = Gson()

example/exampleApp/android/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ buildscript {
22
ext {
33
buildToolsVersion = "34.0.0"
44
minSdkVersion = 23
5-
compileSdkVersion = 34
6-
targetSdkVersion = 34
7-
ndkVersion = "25.1.8937393"
5+
compileSdkVersion = 35
6+
targetSdkVersion = 35
7+
ndkVersion = "26.1.10909125"
88
kotlinVersion = "1.8.0"
9+
cmakeVersion = "3.22.1"
910
}
1011
repositories {
1112
google()

example/exampleApp/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"ios": "react-native run-ios",
88
"lint": "eslint .",
99
"start": "react-native start",
10+
"wipe": "rm -rf ./node_modules && rm -f yarn.lock && rm -f yarn-error.log && cd ./ios && rm -rf ./Pods && rm -f Podfile.lock && cd ../android && rm -rf ./build && rm -rf ./.gradle && cd ./app && rm -rf ./build && cd ../../",
11+
"assemble-debug": "mkdir -p android/app/src/main/assets && npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ && cd android && ./gradlew assembleDebug",
1012
"test": "jest"
1113
},
1214
"dependencies": {
@@ -16,10 +18,10 @@
1618
"mindbox-sdk": "^2.13.1",
1719
"react": "18.2.0",
1820
"react-native": "0.74.0",
19-
"react-native-gesture-handler": "^2.21.2",
20-
"react-native-permissions": "^5.0.0",
21+
"react-native-gesture-handler": "2.21.2",
22+
"react-native-permissions": "^5.4.0",
2123
"react-native-safe-area-context": "^4.9.0",
22-
"react-native-screens": "^3.29.0",
24+
"react-native-screens": "^4.0.0",
2325
"react-native-snackbar": "^2.8.0"
2426
},
2527
"devDependencies": {

0 commit comments

Comments
 (0)