Skip to content

Commit 4306601

Browse files
authored
Merge pull request #125 from mindbox-cloud/release/2.11.0
Release/2.11.0
2 parents 8feceec + 2cb7b44 commit 4306601

File tree

23 files changed

+370
-39
lines changed

23 files changed

+370
-39
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build application after merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- 'feature/*'
8+
- 'develop'
9+
10+
jobs:
11+
trigger:
12+
runs-on: macos-latest
13+
if: github.event.pull_request.merged == true
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Get last 3 commit messages
19+
run: |
20+
commits=$(git log -3 --pretty=format:"%s")
21+
echo "commits=$commits" >> $GITHUB_ENV
22+
23+
- name: Get Flutter Mindbox SDK Version
24+
run: |
25+
sdkVersion=$(grep 'version:' mindbox/pubspec.yaml | awk '{print $2}')
26+
echo "sdkVersion=$sdkVersion" >> $GITHUB_ENV
27+
28+
- name: Trigger build workflow in flutter-app repo
29+
uses: benc-uk/workflow-dispatch@v1
30+
with:
31+
token: ${{ secrets.PAT_FLUTTER_APP }}
32+
workflow: buildApplicationAfterTrigger.yml
33+
repo: mindbox-cloud/flutter-app
34+
ref: develop
35+
inputs: '{"branch": "{{ github.head_ref }}", "commits": "${{ env.commits }}", "sdkVersion": "${{ env.sdkVersion }}"}'

example/flutter_example/ios/Podfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ flutter_ios_podfile_setup
3030
target 'Runner' do
3131
use_frameworks!
3232
use_modular_headers!
33-
33+
# add this pod if doesn't use MindboxFlutterAppDelegate
34+
pod 'Mindbox'
3435
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3536
# target 'RunnerTests' do
3637
# inherit! :search_paths
@@ -41,12 +42,12 @@ end
4142

4243
target 'MindboxNotificationServiceExtension' do
4344
use_frameworks!
44-
pod 'MindboxNotifications', '2.10.1'
45+
pod 'MindboxNotifications', '2.10.2'
4546
end
4647

4748
target 'MindboxNotificationContentExtension' do
4849
use_frameworks!
49-
pod 'MindboxNotifications', '2.10.1'
50+
pod 'MindboxNotifications', '2.10.2'
5051
end
5152

5253
post_install do |installer|

example/flutter_example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1212
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
1313
3A04C4242C18A6EA008FB1C3 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A04C41C2C183779008FB1C3 /* Models.swift */; };
14+
3AFCC3DC2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AFCC3DB2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift */; };
1415
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1516
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
1617
8B81E312DFA9C6FD4EDFB0F6 /* Pods_MindboxNotificationContentExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 201DB479D6282529C705748E /* Pods_MindboxNotificationContentExtension.framework */; };
@@ -84,6 +85,7 @@
8485
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8586
3A04C41C2C183779008FB1C3 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
8687
3A04C4202C18A4E0008FB1C3 /* Mindbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Mindbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
88+
3AFCC3DB2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegateUsedMindboxDelegate.swift; sourceTree = "<group>"; };
8789
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
8890
4AC547651623FA3602973E87 /* Pods_MindboxNotificationServiceExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MindboxNotificationServiceExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8991
4C419D08BE184EB1CC17FC7F /* Pods-MindboxNotificationContentExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MindboxNotificationContentExtension.release.xcconfig"; path = "Target Support Files/Pods-MindboxNotificationContentExtension/Pods-MindboxNotificationContentExtension.release.xcconfig"; sourceTree = "<group>"; };
@@ -231,6 +233,7 @@
231233
97C146F01CF9000F007C117D /* Runner */ = {
232234
isa = PBXGroup;
233235
children = (
236+
3AFCC3DB2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift */,
234237
E19AAF922BD7F53B002D7897 /* Runner.entitlements */,
235238
97C146FA1CF9000F007C117D /* Main.storyboard */,
236239
97C146FD1CF9000F007C117D /* Assets.xcassets */,
@@ -579,6 +582,7 @@
579582
buildActionMask = 2147483647;
580583
files = (
581584
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
585+
3AFCC3DC2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift in Sources */,
582586
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
583587
);
584588
runOnlyForDeploymentPostprocessing = 0;

example/flutter_example/ios/Runner/AppDelegate.swift

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,101 @@ import Mindbox
55
import UserNotifications
66

77
@UIApplicationMain
8-
@objc class AppDelegate: MindboxFlutterAppDelegate {
8+
@objc class AppDelegate: FlutterAppDelegate {
99
private var eventSink: FlutterEventSink?
1010

11-
override func shouldRegisterForRemoteNotifications() -> Bool {
12-
return true
13-
}
14-
1511
override func application(
1612
_ application: UIApplication,
1713
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
1814
) -> Bool {
15+
1916
UIApplication.shared.registerForRemoteNotifications()
20-
GeneratedPluginRegistrant.register(with: self)
2117

18+
// Calling the notification request method
19+
registerForRemoteNotifications()
20+
21+
// tracking sources of referrals to the application via push notifications
22+
Mindbox.shared.track(.launch(launchOptions))
23+
24+
// registering background tasks for iOS above 13
25+
if #available(iOS 13.0, *) {
26+
Mindbox.shared.registerBGTasks()
27+
} else {
28+
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
29+
}
30+
31+
//Used for notification center
2232
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
2333
let eventChannel = FlutterEventChannel(name: "cloud.mindbox.flutter_example.notifications", binaryMessenger: controller.binaryMessenger)
2434
eventChannel.setStreamHandler(self)
2535

26-
UNUserNotificationCenter.current().delegate = self
27-
36+
GeneratedPluginRegistrant.register(with: self)
2837
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
2938
}
3039

31-
func notifyFlutterNewData() {
32-
if let eventSink = eventSink {
33-
eventSink("newNotification")
40+
override func application(
41+
_ application: UIApplication,
42+
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
43+
// Transfer to SDK APNs token
44+
Mindbox.shared.apnsTokenUpdate(deviceToken: deviceToken)
3445
}
35-
}
46+
47+
override func application(
48+
_ application: UIApplication,
49+
continue userActivity: NSUserActivity,
50+
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
51+
) -> Bool {
52+
// Passing the link if the application is opened via universalLink
53+
Mindbox.shared.track(.universalLink(userActivity))
54+
return super.application(application, continue: userActivity, restorationHandler:
55+
restorationHandler)
56+
}
57+
58+
// Register background tasks for iOS up to 13
59+
override func application(
60+
_ application: UIApplication,
61+
performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
62+
Mindbox.shared.application(application, performFetchWithCompletionHandler: completionHandler)
63+
}
64+
3665

3766
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
38-
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
67+
//Implement display of standard notifications
68+
completionHandler([.alert, .badge, .sound])
3969
notifyFlutterNewData()
4070
}
4171

72+
override func userNotificationCenter(
73+
_ center: UNUserNotificationCenter,
74+
didReceive response: UNNotificationResponse,
75+
withCompletionHandler completionHandler: @escaping () -> Void) {
76+
// Send click to Mindbox
77+
Mindbox.shared.pushClicked(response: response)
78+
79+
// Sending the fact that the application was opened when switching to push notification
80+
Mindbox.shared.track(.push(response))
81+
completionHandler()
82+
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
83+
}
84+
85+
func registerForRemoteNotifications() {
86+
UNUserNotificationCenter.current().delegate = self
87+
DispatchQueue.main.async {
88+
UNUserNotificationCenter.current().requestAuthorization(options: [ .alert, .sound, .badge]) { granted, error in
89+
print("Permission granted: \(granted)")
90+
if let error = error {
91+
print("NotificationsRequestAuthorization failed with error: \(error.localizedDescription)")
92+
}
93+
Mindbox.shared.notificationsRequestAuthorization(granted: granted)
94+
}
95+
}
96+
}
97+
98+
func notifyFlutterNewData() {
99+
if let eventSink = eventSink {
100+
eventSink("newNotification")
101+
}
102+
}
42103
}
43104

44105
extension AppDelegate: FlutterStreamHandler {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import UIKit
2+
import Flutter
3+
import mindbox_ios
4+
import Mindbox
5+
import UserNotifications
6+
7+
8+
@objc class AppDelegateUsedMindboxDelegate: MindboxFlutterAppDelegate {
9+
private var eventSink: FlutterEventSink?
10+
11+
override func shouldRegisterForRemoteNotifications() -> Bool {
12+
return true
13+
}
14+
15+
override func application(
16+
_ application: UIApplication,
17+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
18+
) -> Bool {
19+
UIApplication.shared.registerForRemoteNotifications()
20+
GeneratedPluginRegistrant.register(with: self)
21+
22+
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
23+
let eventChannel = FlutterEventChannel(name: "cloud.mindbox.flutter_example.notifications", binaryMessenger: controller.binaryMessenger)
24+
eventChannel.setStreamHandler(self)
25+
26+
UNUserNotificationCenter.current().delegate = self
27+
28+
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
29+
}
30+
31+
func notifyFlutterNewData() {
32+
if let eventSink = eventSink {
33+
eventSink("newNotification")
34+
}
35+
}
36+
37+
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
38+
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
39+
notifyFlutterNewData()
40+
}
41+
42+
}
43+
44+
extension AppDelegateUsedMindboxDelegate: FlutterStreamHandler {
45+
func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
46+
self.eventSink = events
47+
return nil
48+
}
49+
50+
func onCancel(withArguments arguments: Any?) -> FlutterError? {
51+
self.eventSink = nil
52+
return nil
53+
}
54+
}

mindbox/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.11.0
2+
3+
* Upgrade native Android SDK dependency to v2.11.0.
4+
* Upgrade native iOS SDK dependency to v2.11.0.
5+
16
## 2.10.2-rc
27

38
* Upgrade native Android SDK dependency to v2.10.2-rc.

mindbox/lib/mindbox.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,23 @@ class Mindbox {
153153
MindboxPlatform.instance
154154
.updateNotificationPermissionStatus(granted: granted);
155155
}
156+
157+
/// Writes a log message to the native Mindbox logging system.
158+
///
159+
/// Usage example:
160+
///
161+
/// ```dart
162+
/// Mindbox.instance.writeNativeLog(
163+
/// message: 'This is a debug message',
164+
/// logLevel: LogLevel.debug,
165+
/// );
166+
/// ```
167+
///
168+
/// [message]: The message to be logged.
169+
/// [logLevel]: The severity level of the log message [LogLevel].
170+
///
171+
void writeNativeLog({required String message, required LogLevel logLevel}) {
172+
MindboxPlatform.instance
173+
.writeNativeLog(message: message, logLevel: logLevel);
174+
}
156175
}

mindbox/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: mindbox
22
description: Flutter Mindbox SDK. Plugin wrapper over of Mindbox iOS/Android SDK.
3-
version: 2.10.2-rc
3+
version: 2.11.0
44
homepage: https://mindbox.cloud/
55
repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox
66
documentation: https://developers.mindbox.ru/docs/flutter-sdk-integration
@@ -20,9 +20,9 @@ flutter:
2020
dependencies:
2121
flutter:
2222
sdk: flutter
23-
mindbox_android: ^2.10.2-rc
24-
mindbox_ios: ^2.10.2-rc
25-
mindbox_platform_interface: ^2.10.2-rc
23+
mindbox_android: ^2.11.0
24+
mindbox_ios: ^2.11.0
25+
mindbox_platform_interface: ^2.11.0
2626

2727
dev_dependencies:
2828
flutter_test:

mindbox_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.11.0
2+
3+
* Upgrade native Android SDK dependency to v2.11.0.
4+
15
## 2.10.2-rc
26

37
* Upgrade native Android SDK dependency to v2.10.2-rc.

mindbox_android/android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ android {
4848

4949
dependencies {
5050
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51-
52-
api 'cloud.mindbox:mobile-sdk:2.10.2-rc'
51+
api 'cloud.mindbox:mobile-sdk:2.11.0'
5352
}

mindbox_android/android/src/main/kotlin/cloud/mindbox/mindbox_android/MindboxAndroidPlugin.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,26 @@ class MindboxAndroidPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, Ne
155155
"updateNotificationPermissionStatus" -> {
156156
Mindbox.updateNotificationPermissionStatus(context = context)
157157
}
158+
159+
"writeNativeLog" -> {
160+
if (call.arguments is List<*>) {
161+
val args = call.arguments as List<*>
162+
if (args.size < 2) {
163+
result.error("-1", "error", "Wrong argument count")
164+
}
165+
try {
166+
val message: String? = args[0] as String
167+
val logIndex: Int = args[1] as Int
168+
val logLevel: Level = Level.values()[logIndex]
169+
Mindbox.writeLog(message!!, logLevel)
170+
result.success(0)
171+
}
172+
catch (e: Exception)
173+
{
174+
result.error("-1", "error", "Exception occurred: ${e.message}")
175+
}
176+
}
177+
}
158178
else -> {
159179
result.notImplemented()
160180
}

mindbox_android/lib/src/mindbox_android_platform.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,9 @@ class MindboxAndroidPlatform extends MindboxPlatform {
101101
void updateNotificationPermissionStatus({required bool granted}) {
102102
_methodHandler.updateNotificationPermissionStatus(granted: granted);
103103
}
104+
105+
@override
106+
void writeNativeLog({required String message, required LogLevel logLevel}) {
107+
_methodHandler.writeNativeLog(message: message, logLevel: logLevel);
108+
}
104109
}

mindbox_android/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: mindbox_android
22
description: The implementation of 'mindbox' plugin for the Android platform.
3-
version: 2.10.2-rc
3+
version: 2.11.0
44
homepage: https://mindbox.cloud/
55
repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox_android
66

@@ -19,7 +19,7 @@ flutter:
1919
dependencies:
2020
flutter:
2121
sdk: flutter
22-
mindbox_platform_interface: ^2.10.2-rc
22+
mindbox_platform_interface: ^2.11.0
2323

2424
dev_dependencies:
2525
flutter_test:

mindbox_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.11.0
2+
3+
* Upgrade native iOS SDK dependency to v2.11.0.
4+
15
## 2.10.2-rc
26

37
* Upgrade native iOS SDK dependency to v2.10.3-rc.

0 commit comments

Comments
 (0)