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
4 changes: 2 additions & 2 deletions MindboxSdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => "12.0" }
s.platforms = { :ios => "15.1" }
Comment thread
sergeysozinov marked this conversation as resolved.
s.source = { :git => "https://github.com/mindbox-moscow/react-native-sdk/.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "React-Core"
install_modules_dependencies(s)
Comment thread
sergeysozinov marked this conversation as resolved.

s.dependency "Mindbox", "2.15.0"
s.dependency "MindboxNotifications", "2.15.0"
Expand Down
23 changes: 0 additions & 23 deletions android/src/main/java/com/mindboxsdk/MindboxSdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MindboxSdkModule(
}

private var deviceUuidSubscription: String? = null
private var fmsTokenSubscription: String? = null
private var getTokensSubscription: String? = null

private fun emitPushFromDelivery(bundle: Bundle) {
Expand Down Expand Up @@ -165,19 +164,6 @@ class MindboxSdkModule(
}
}

override fun getFMSToken(promise: Promise) {
try {
if (fmsTokenSubscription != null) {
Mindbox.disposePushTokenSubscription(fmsTokenSubscription!!)
}
fmsTokenSubscription = Mindbox.subscribePushToken { fmsToken ->
promise.resolve(fmsToken)
}
} catch (error: Throwable) {
promise.reject(error)
}
}

override fun getTokens(promise: Promise) {
try {
if (getTokensSubscription != null) {
Expand All @@ -191,15 +177,6 @@ class MindboxSdkModule(
}
}

override fun updateFMSToken(token: String, promise: Promise) {
try {
Mindbox.updateNotificationPermissionStatus(reactApplicationContext.applicationContext)
promise.resolve(true)
} catch (error: Throwable) {
promise.reject(error)
}
}

override fun executeAsyncOperation(operationSystemName: String, operationBody: String, promise: Promise) {
Mindbox.executeAsyncOperation(
reactApplicationContext.applicationContext,
Expand Down
78 changes: 31 additions & 47 deletions example/exampleApp/ios/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
import UIKit
import React
import React_RCTAppDelegate
import UserNotifications
import Mindbox
import MindboxSdk


// https://developers.mindbox.ru/docs/ios-send-push-notifications-react-native
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

var window: UIWindow?
var bridge: RCTBridge!

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
@main
class AppDelegate: RCTAppDelegate, UNUserNotificationCenterDelegate {

override func application(_ application: UIApplication,
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

// Setting up React Native bridge
bridge = RCTBridge(delegate: self, launchOptions: launchOptions)
let rootView = RCTRootView(bridge: bridge, moduleName: "exampleApp", initialProperties: nil)

// Configuring the application window
self.window = UIWindow(frame: UIScreen.main.bounds)
let rootViewController = UIViewController()
rootViewController.view = rootView
self.window!.rootViewController = rootViewController
self.window!.makeKeyAndVisible()

// https://developers.mindbox.ru/docs/ios-app-start-tracking-react-native
// Tracking app launch for analytics
let trackVisitData = TrackVisitData()
Expand All @@ -42,28 +28,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
} else {
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
}

return true
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

func notifyReactNative() {
if let bridge = bridge, let eventEmitter = bridge.module(for: NotificationModule.self) as? NotificationModule {
eventEmitter.notifyReactNative()
}
if let eventEmitter = bridge?.module(for: NotificationModule.self) as? NotificationModule {
eventEmitter.notifyReactNative()
}
}

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

// Updating APNS token in Mindbox
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
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
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
override func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
let trackVisitData = TrackVisitData()
trackVisitData.universalLink = userActivity
Mindbox.shared.track(data: trackVisitData)
Expand All @@ -78,34 +69,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

// Handling push notification clicks
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
// https://developers.mindbox.ru/docs/ios-get-click-react-native
Mindbox.shared.pushClicked(response: response)
// https://developers.mindbox.ru/docs/ios-app-start-tracking-react-native
// Tracking push notification clicks for analytics
let trackVisitData = TrackVisitData()
trackVisitData.push = response
Mindbox.shared.track(data: trackVisitData)

// Emitting event for further handling in JavaScript
// https://developers.mindbox.ru/docs/flutter-push-navigation-react-native
MindboxJsDelivery.emitEvent(response)

completionHandler()
}
}

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

override func extraModules(for bridge: RCTBridge!) -> [RCTBridgeModule] {
[NotificationModule()]
}
Comment thread
sergeysozinov marked this conversation as resolved.

override func bundleURL() -> URL? {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
Comment thread
sergeysozinov marked this conversation as resolved.

func extraModules(for bridge: RCTBridge!) -> [RCTBridgeModule]! {
var modules = [RCTBridgeModule]()
modules.append(NotificationModule())
return modules
}
}
2 changes: 0 additions & 2 deletions example/exampleApp/ios/Swift.swift

This file was deleted.

4 changes: 0 additions & 4 deletions example/exampleApp/ios/exampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
3A027BAE2C3BFC4D005415BB /* NotificationModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A027BAD2C3BFC4D005415BB /* NotificationModule.m */; };
3A175C362C3D1B800027776A /* PushAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A175C322C3D16C70027776A /* PushAction.swift */; };
3A175C372C3D1B800027776A /* MindboxRemoteMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A175C342C3D16F50027776A /* MindboxRemoteMessage.swift */; };
3A88FC072B6BDD900046E687 /* Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A88FC062B6BDD900046E687 /* Swift.swift */; };
3A88FC092B6BDF360046E687 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A88FC082B6BDF360046E687 /* AppDelegate.swift */; };
3ACCD5142B72826700C94F45 /* MindboxNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 3ACCD50D2B72826700C94F45 /* MindboxNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
3ACCD51C2B728BD500C94F45 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ACCD51B2B728BD500C94F45 /* NotificationService.swift */; };
Expand Down Expand Up @@ -69,7 +68,6 @@
3A027BAD2C3BFC4D005415BB /* NotificationModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationModule.m; sourceTree = "<group>"; };
3A175C322C3D16C70027776A /* PushAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushAction.swift; sourceTree = "<group>"; };
3A175C342C3D16F50027776A /* MindboxRemoteMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MindboxRemoteMessage.swift; sourceTree = "<group>"; };
3A88FC062B6BDD900046E687 /* Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift.swift; sourceTree = "<group>"; };
3A88FC082B6BDF360046E687 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3A88FC0A2B6BF2840046E687 /* exampleApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "exampleApp-Bridging-Header.h"; sourceTree = "<group>"; };
3A88FC0B2B6CEE180046E687 /* exampleApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = exampleApp.entitlements; path = exampleApp/exampleApp.entitlements; sourceTree = "<group>"; };
Expand Down Expand Up @@ -200,7 +198,6 @@
3A027BAD2C3BFC4D005415BB /* NotificationModule.m */,
3A027BAB2C3BF24F005415BB /* NotificationModule.swift */,
3A88FC0A2B6BF2840046E687 /* exampleApp-Bridging-Header.h */,
3A88FC062B6BDD900046E687 /* Swift.swift */,
13B07FAE1A68108700A75B9A /* exampleApp */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
3ACCD50E2B72826700C94F45 /* MindboxNotificationServiceExtension */,
Expand Down Expand Up @@ -532,7 +529,6 @@
files = (
3A027BAE2C3BFC4D005415BB /* NotificationModule.m in Sources */,
3A88FC092B6BDF360046E687 /* AppDelegate.swift in Sources */,
3A88FC072B6BDD900046E687 /* Swift.swift in Sources */,
3A027BAC2C3BF24F005415BB /* NotificationModule.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
17 changes: 0 additions & 17 deletions ios/MindboxJsDelivery.h

This file was deleted.

148 changes: 0 additions & 148 deletions ios/MindboxJsDelivery.m

This file was deleted.

Loading
Loading