Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@

<meta-data
android:name="com.mindbox.sdk.AUTO_INIT_ENABLED"
android:value="false" />
android:value="true" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import com.facebook.react.defaults.DefaultReactActivityDelegate
import com.mindboxsdk.MindboxJsDelivery

class MainActivity : ReactActivity() {
private fun handlePushIntent(intent: Intent) {
Mindbox.onNewIntent(intent)
Mindbox.onPushClicked(applicationContext, intent)
MindboxJsDelivery.sendPushClicked(intent)
}

override fun getMainComponentName(): String = "exampleApp"

Expand All @@ -29,11 +24,5 @@ class MainActivity : ReactActivity() {
} else {
Mindbox.writeLog("[RN][exampleApp] Old architecture", Level.DEBUG)
}
handlePushIntent(intent)
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handlePushIntent(intent)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
Mindbox.initPushServices(this, listOf(MindboxFirebase, MindboxHuawei, MindboxRuStore))
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
load()
Expand Down
43 changes: 4 additions & 39 deletions example/exampleApp/ios/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,36 @@ class AppDelegate: RCTAppDelegate, UNUserNotificationCenterDelegate {
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
moduleName = "exampleApp"
initialProps = [:]
// Set the current instance of UNUserNotificationCenter's delegate to self.
// This enables the AppDelegate to respond to notification events
UNUserNotificationCenter.current().delegate = self
// https://developers.mindbox.ru/docs/ios-app-start-tracking-react-native
// Tracking app launch for analytics
let trackVisitData = TrackVisitData()
trackVisitData.launchOptions = launchOptions
Mindbox.shared.track(data: trackVisitData)

// Register background tasks for iOS 13 and later, or set background fetch interval for earlier versions
if #available(iOS 13.0, *) {
Mindbox.shared.registerBGTasks()
} else {
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
}
MindboxApp.configure(launchOptions: launchOptions)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

func notifyReactNativeAboutNotificationCenterUpdate() {
NotificationCenter.default.post(name: NotificationCenterStorage.notificationCenterUpdatedName, object: nil)
}

// Handling remote notification fetch completion
override func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Mindbox.shared.application(application, performFetchWithCompletionHandler: completionHandler)
notifyReactNativeAboutNotificationCenterUpdate()
Mindbox.shared.application(application, performFetchWithCompletionHandler: completionHandler)
}

// Updating APNS token in Mindbox
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Mindbox.shared.apnsTokenUpdate(deviceToken: deviceToken)
}

// Handling Universal Links
// https://developers.mindbox.ru/docs/ios-app-start-tracking-react-native
override func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
let trackVisitData = TrackVisitData()
trackVisitData.universalLink = userActivity
Mindbox.shared.track(data: trackVisitData)
return true
}

// Displaying notifications when the app is active
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
notifyReactNativeAboutNotificationCenterUpdate()
completionHandler([.alert, .sound, .badge])
}

// Handling push notification clicks
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
Mindbox.shared.pushClicked(response: response)
let trackVisitData = TrackVisitData()
trackVisitData.push = response
Mindbox.shared.track(data: trackVisitData)
MindboxJsDelivery.emitEvent(response)
notifyReactNativeAboutNotificationCenterUpdate()
completionHandler()
}

override func sourceURL(for bridge: RCTBridge!) -> URL! {
bundleURL()
}

override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
Expand Down
2 changes: 1 addition & 1 deletion example/exampleApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "jest"
},
"dependencies": {
"mindbox-sdk": "^2.15.0",
"mindbox-sdk": "^3.0.0-rc",
"react": "18.3.1",
"react-native": "0.76.0",
"react-native-permissions": "^5.4.0",
Expand Down
Loading