Skip to content

Commit

Permalink
Merge pull request #125 from mindbox-cloud/release/2.11.0
Browse files Browse the repository at this point in the history
Release/2.11.0
Vailence authored Sep 12, 2024

Verified

This commit was signed with the committer’s verified signature.
zregvart Zoran Regvart
2 parents 8feceec + 2cb7b44 commit 4306601
Showing 23 changed files with 370 additions and 39 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/trigger-build-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build application after merge

on:
pull_request:
types: [closed]
branches:
- 'feature/*'
- 'develop'

jobs:
trigger:
runs-on: macos-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get last 3 commit messages
run: |
commits=$(git log -3 --pretty=format:"%s")
echo "commits=$commits" >> $GITHUB_ENV
- name: Get Flutter Mindbox SDK Version
run: |
sdkVersion=$(grep 'version:' mindbox/pubspec.yaml | awk '{print $2}')
echo "sdkVersion=$sdkVersion" >> $GITHUB_ENV
- name: Trigger build workflow in flutter-app repo
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT_FLUTTER_APP }}
workflow: buildApplicationAfterTrigger.yml
repo: mindbox-cloud/flutter-app
ref: develop
inputs: '{"branch": "{{ github.head_ref }}", "commits": "${{ env.commits }}", "sdkVersion": "${{ env.sdkVersion }}"}'
7 changes: 4 additions & 3 deletions example/flutter_example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -30,7 +30,8 @@ flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!

# add this pod if doesn't use MindboxFlutterAppDelegate
pod 'Mindbox'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
# target 'RunnerTests' do
# inherit! :search_paths
@@ -41,12 +42,12 @@ end

target 'MindboxNotificationServiceExtension' do
use_frameworks!
pod 'MindboxNotifications', '2.10.1'
pod 'MindboxNotifications', '2.10.2'
end

target 'MindboxNotificationContentExtension' do
use_frameworks!
pod 'MindboxNotifications', '2.10.1'
pod 'MindboxNotifications', '2.10.2'
end

post_install do |installer|
4 changes: 4 additions & 0 deletions example/flutter_example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3A04C4242C18A6EA008FB1C3 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A04C41C2C183779008FB1C3 /* Models.swift */; };
3AFCC3DC2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AFCC3DB2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
8B81E312DFA9C6FD4EDFB0F6 /* Pods_MindboxNotificationContentExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 201DB479D6282529C705748E /* Pods_MindboxNotificationContentExtension.framework */; };
@@ -84,6 +85,7 @@
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3A04C41C2C183779008FB1C3 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
3A04C4202C18A4E0008FB1C3 /* Mindbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Mindbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3AFCC3DB2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegateUsedMindboxDelegate.swift; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4AC547651623FA3602973E87 /* Pods_MindboxNotificationServiceExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MindboxNotificationServiceExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
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 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
3AFCC3DB2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift */,
E19AAF922BD7F53B002D7897 /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
@@ -579,6 +582,7 @@
buildActionMask = 2147483647;
files = (
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
3AFCC3DC2C6A0B4000F047AB /* AppDelegateUsedMindboxDelegate.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
87 changes: 74 additions & 13 deletions example/flutter_example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -5,40 +5,101 @@ import Mindbox
import UserNotifications

@UIApplicationMain
@objc class AppDelegate: MindboxFlutterAppDelegate {
@objc class AppDelegate: FlutterAppDelegate {
private var eventSink: FlutterEventSink?

override func shouldRegisterForRemoteNotifications() -> Bool {
return true
}

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

UIApplication.shared.registerForRemoteNotifications()
GeneratedPluginRegistrant.register(with: self)

// Calling the notification request method
registerForRemoteNotifications()

// tracking sources of referrals to the application via push notifications
Mindbox.shared.track(.launch(launchOptions))

// registering background tasks for iOS above 13
if #available(iOS 13.0, *) {
Mindbox.shared.registerBGTasks()
} else {
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
}

//Used for notification center
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let eventChannel = FlutterEventChannel(name: "cloud.mindbox.flutter_example.notifications", binaryMessenger: controller.binaryMessenger)
eventChannel.setStreamHandler(self)

UNUserNotificationCenter.current().delegate = self

GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

func notifyFlutterNewData() {
if let eventSink = eventSink {
eventSink("newNotification")
override func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// Transfer to SDK APNs token
Mindbox.shared.apnsTokenUpdate(deviceToken: deviceToken)
}
}

override func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
// Passing the link if the application is opened via universalLink
Mindbox.shared.track(.universalLink(userActivity))
return super.application(application, continue: userActivity, restorationHandler:
restorationHandler)
}

// Register background tasks for iOS up to 13
override func application(
_ application: UIApplication,
performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Mindbox.shared.application(application, performFetchWithCompletionHandler: completionHandler)
}


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

override func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
// Send click to Mindbox
Mindbox.shared.pushClicked(response: response)

// Sending the fact that the application was opened when switching to push notification
Mindbox.shared.track(.push(response))
completionHandler()
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}

func registerForRemoteNotifications() {
UNUserNotificationCenter.current().delegate = self
DispatchQueue.main.async {
UNUserNotificationCenter.current().requestAuthorization(options: [ .alert, .sound, .badge]) { granted, error in
print("Permission granted: \(granted)")
if let error = error {
print("NotificationsRequestAuthorization failed with error: \(error.localizedDescription)")
}
Mindbox.shared.notificationsRequestAuthorization(granted: granted)
}
}
}

func notifyFlutterNewData() {
if let eventSink = eventSink {
eventSink("newNotification")
}
}
}

extension AppDelegate: FlutterStreamHandler {
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import UIKit
import Flutter
import mindbox_ios
import Mindbox
import UserNotifications


@objc class AppDelegateUsedMindboxDelegate: MindboxFlutterAppDelegate {
private var eventSink: FlutterEventSink?

override func shouldRegisterForRemoteNotifications() -> Bool {
return true
}

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
UIApplication.shared.registerForRemoteNotifications()
GeneratedPluginRegistrant.register(with: self)

let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let eventChannel = FlutterEventChannel(name: "cloud.mindbox.flutter_example.notifications", binaryMessenger: controller.binaryMessenger)
eventChannel.setStreamHandler(self)

UNUserNotificationCenter.current().delegate = self

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

func notifyFlutterNewData() {
if let eventSink = eventSink {
eventSink("newNotification")
}
}

override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
notifyFlutterNewData()
}

}

extension AppDelegateUsedMindboxDelegate: FlutterStreamHandler {
func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
self.eventSink = events
return nil
}

func onCancel(withArguments arguments: Any?) -> FlutterError? {
self.eventSink = nil
return nil
}
}
5 changes: 5 additions & 0 deletions mindbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.11.0

* Upgrade native Android SDK dependency to v2.11.0.
* Upgrade native iOS SDK dependency to v2.11.0.

## 2.10.2-rc

* Upgrade native Android SDK dependency to v2.10.2-rc.
19 changes: 19 additions & 0 deletions mindbox/lib/mindbox.dart
Original file line number Diff line number Diff line change
@@ -153,4 +153,23 @@ class Mindbox {
MindboxPlatform.instance
.updateNotificationPermissionStatus(granted: granted);
}

/// Writes a log message to the native Mindbox logging system.
///
/// Usage example:
///
/// ```dart
/// Mindbox.instance.writeNativeLog(
/// message: 'This is a debug message',
/// logLevel: LogLevel.debug,
/// );
/// ```
///
/// [message]: The message to be logged.
/// [logLevel]: The severity level of the log message [LogLevel].
///
void writeNativeLog({required String message, required LogLevel logLevel}) {
MindboxPlatform.instance
.writeNativeLog(message: message, logLevel: logLevel);
}
}
8 changes: 4 additions & 4 deletions mindbox/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mindbox
description: Flutter Mindbox SDK. Plugin wrapper over of Mindbox iOS/Android SDK.
version: 2.10.2-rc
version: 2.11.0
homepage: https://mindbox.cloud/
repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox
documentation: https://developers.mindbox.ru/docs/flutter-sdk-integration
@@ -20,9 +20,9 @@ flutter:
dependencies:
flutter:
sdk: flutter
mindbox_android: ^2.10.2-rc
mindbox_ios: ^2.10.2-rc
mindbox_platform_interface: ^2.10.2-rc
mindbox_android: ^2.11.0
mindbox_ios: ^2.11.0
mindbox_platform_interface: ^2.11.0

dev_dependencies:
flutter_test:
4 changes: 4 additions & 0 deletions mindbox_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.11.0

* Upgrade native Android SDK dependency to v2.11.0.

## 2.10.2-rc

* Upgrade native Android SDK dependency to v2.10.2-rc.
3 changes: 1 addition & 2 deletions mindbox_android/android/build.gradle
Original file line number Diff line number Diff line change
@@ -48,6 +48,5 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

api 'cloud.mindbox:mobile-sdk:2.10.2-rc'
api 'cloud.mindbox:mobile-sdk:2.11.0'
}
Original file line number Diff line number Diff line change
@@ -155,6 +155,26 @@ class MindboxAndroidPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, Ne
"updateNotificationPermissionStatus" -> {
Mindbox.updateNotificationPermissionStatus(context = context)
}

"writeNativeLog" -> {
if (call.arguments is List<*>) {
val args = call.arguments as List<*>
if (args.size < 2) {
result.error("-1", "error", "Wrong argument count")
}
try {
val message: String? = args[0] as String
val logIndex: Int = args[1] as Int
val logLevel: Level = Level.values()[logIndex]
Mindbox.writeLog(message!!, logLevel)
result.success(0)
}
catch (e: Exception)
{
result.error("-1", "error", "Exception occurred: ${e.message}")
}
}
}
else -> {
result.notImplemented()
}
5 changes: 5 additions & 0 deletions mindbox_android/lib/src/mindbox_android_platform.dart
Original file line number Diff line number Diff line change
@@ -101,4 +101,9 @@ class MindboxAndroidPlatform extends MindboxPlatform {
void updateNotificationPermissionStatus({required bool granted}) {
_methodHandler.updateNotificationPermissionStatus(granted: granted);
}

@override
void writeNativeLog({required String message, required LogLevel logLevel}) {
_methodHandler.writeNativeLog(message: message, logLevel: logLevel);
}
}
4 changes: 2 additions & 2 deletions mindbox_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mindbox_android
description: The implementation of 'mindbox' plugin for the Android platform.
version: 2.10.2-rc
version: 2.11.0
homepage: https://mindbox.cloud/
repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox_android

@@ -19,7 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
mindbox_platform_interface: ^2.10.2-rc
mindbox_platform_interface: ^2.11.0

dev_dependencies:
flutter_test:
4 changes: 4 additions & 0 deletions mindbox_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.11.0

* Upgrade native iOS SDK dependency to v2.11.0.

## 2.10.2-rc

* Upgrade native iOS SDK dependency to v2.10.3-rc.
32 changes: 32 additions & 0 deletions mindbox_ios/ios/Classes/SwiftMindboxIosPlugin.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Flutter
import UIKit
import Mindbox
import MindboxLogger



@@ -164,6 +165,37 @@ public class SwiftMindboxIosPlugin: NSObject, FlutterPlugin {
return
}
Mindbox.shared.notificationsRequestAuthorization(granted: granted)

case "writeNativeLog":
guard let args = call.arguments as? [Any], args.count >= 2 else {
result(FlutterError(code: "-1", message: "error", details: "Wrong argument count or type"))
return
}

guard let message = args[0] as? String,
let levelIndex = args[1] as? Int else {
result(FlutterError(code: "-1", message: "error", details: "Wrong argument type"))
return
}
let logLevel: LogLevel

switch levelIndex {
case 0:
logLevel = .debug
case 1:
logLevel = .info
case 2:
logLevel = .default
case 3:
logLevel = .error
case 4:
logLevel = .fault
default:
logLevel = .none
}
Mindbox.logger.log(level: logLevel, message: message)
result(0)

default:
result(FlutterMethodNotImplemented)
}
10 changes: 5 additions & 5 deletions mindbox_ios/ios/mindbox_ios.podspec
Original file line number Diff line number Diff line change
@@ -4,20 +4,20 @@
#
Pod::Spec.new do |s|
s.name = 'mindbox_ios'
s.version = '2.10.3-rc'
s.version = '2.11.0'
s.summary = 'Mindbox Flutter SDK'
s.description = <<-DESC
The implementation of 'mindbox' plugin for the iOS platform
DESC
s.homepage = 'https://mindbox.cloud/'
s.license = { :file => '../LICENSE.md' }
s.license = { :file => '../LICENSE' }
s.author = { 'Mindbox' => 'it@mindbox.ru' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'Mindbox', '2.10.3-rc'
s.dependency 'MindboxNotifications', '2.10.3-rc'
s.platform = :ios, '10.0'
s.dependency 'Mindbox', '2.11.0'
s.dependency 'MindboxNotifications', '2.11.0'
s.platform = :ios, '12.0'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
6 changes: 6 additions & 0 deletions mindbox_ios/lib/src/mindbox_ios_platform.dart
Original file line number Diff line number Diff line change
@@ -101,4 +101,10 @@ class MindboxIosPlatform extends MindboxPlatform {
void updateNotificationPermissionStatus({required bool granted}) {
_methodHandler.updateNotificationPermissionStatus(granted: granted);
}

/// Writes a log message to the native Mindbox logging system.
@override
void writeNativeLog({required String message, required LogLevel logLevel}) {
_methodHandler.writeNativeLog(message: message, logLevel: logLevel);
}
}
4 changes: 2 additions & 2 deletions mindbox_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mindbox_ios
description: The implementation of 'mindbox' plugin for the iOS platform.
version: 2.10.2-rc
version: 2.11.0
homepage: https://mindbox.cloud/
repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox_ios

@@ -18,7 +18,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
mindbox_platform_interface: ^2.10.2-rc
mindbox_platform_interface: ^2.11.0

dev_dependencies:
flutter_test:
5 changes: 5 additions & 0 deletions mindbox_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.11.0

* Upgrade native Android SDK dependency to v2.11.0.
* Upgrade native iOS SDK dependency to v2.11.0.

## 2.10.2-rc

* Upgrade native Android SDK dependency to v2.10.2-rc.
5 changes: 5 additions & 0 deletions mindbox_platform_interface/lib/src/mindbox_platform.dart
Original file line number Diff line number Diff line change
@@ -123,6 +123,11 @@ abstract class MindboxPlatform {
void updateNotificationPermissionStatus({required bool granted}) =>
throw UnimplementedError(
'updateNotificationPermissionStatus() has not been implemented');

/// Writes a log message to the native Mindbox logging system.
void writeNativeLog({required String message, required LogLevel logLevel}) =>
throw UnimplementedError(
'writeNativeLog() has not been implemented');
}


Original file line number Diff line number Diff line change
@@ -28,6 +28,13 @@ class _PendingOperations {
final Function? errorCallback;
}

class _PendingPushData {
_PendingPushData({required this.link, required this.payload});

final String link;
final String payload;
}

/// This class contains the necessary logic of the order of method calls
/// for the correct SDK working.
///
@@ -36,6 +43,8 @@ class MindboxMethodHandler {
bool _initialized = false;
final List<_PendingCallbackMethod> _pendingCallbackMethods = [];
final List<_PendingOperations> _pendingOperations = [];
final List<_PendingPushData> _pendingPushData = [];
final String _logPrefix = '[Flutter] ';
PushClickHandler? _pushClickHandler;
InAppClickHandler? _inAppClickHandler;
InAppDismissedHandler? _inAppDismissedHandler;
@@ -84,6 +93,7 @@ class MindboxMethodHandler {
_pendingCallbackMethods.clear();
_pendingOperations.clear();
_initialized = true;
_logInfo('Init in Flutter');
} on PlatformException catch (e) {
throw MindboxInitializeError(
message: e.message ?? '', data: e.details ?? '');
@@ -149,6 +159,15 @@ class MindboxMethodHandler {
required PushClickHandler handler,
}) {
_pushClickHandler = handler;
if (_pendingPushData.isNotEmpty) {
_logInfo('pendingPushData is not empty. Send data to methodHandler');
for (final pushData in _pendingPushData) {
_logInfo('invoke pushClicked method from pending list. '
'Push data: link ${pushData.link},payload = ${pushData.payload}');
_sendPendingPushData(pushData.link, pushData.payload);
}
_pendingPushData.clear();
}
}

/// Method for handling In-app click.
@@ -284,15 +303,32 @@ class MindboxMethodHandler {
data: exception.message!);
}
}
/// Writes a log message to the native Mindbox logging system.
/// [message]: The message to be logged
/// [logLevel]: The severity level of the log message [LogLevel]
void writeNativeLog(
{required String message, required LogLevel logLevel}) async {
await channel
.invokeMethod('writeNativeLog', [_logPrefix + message, logLevel.index]);
}

void _setMethodCallHandler() {
channel.setMethodCallHandler((call) {
switch (call.method) {
case 'pushClicked':
_logInfo('Handle method pushClicked');
if (_pushClickHandler != null) {
if (call.arguments is List) {
_pushClickHandler?.call(call.arguments[0], call.arguments[1]);
_logInfo('Return data from push with parameters link = '
'${call.arguments[0]} and payload = ${call.arguments[1]}');
_sendPendingPushData(call.arguments[0], call.arguments[1]);
}
break;
} else {
_logInfo('pushClickHandler not set. Save push data');
_pendingPushData.add(_PendingPushData(
link: call.arguments[0], payload: call.arguments[1]));
}
break;
case 'onInAppClick':
if (call.arguments is List) {
_inAppClickHandler?.call(
@@ -309,4 +345,21 @@ class MindboxMethodHandler {
});
_methodHandlerSet = true;
}

void _logInfo(String message) {
writeNativeLog(message: message, logLevel: LogLevel.info);
}

void _logError(String message) {
writeNativeLog(message: message, logLevel: LogLevel.error);
}

void _sendPendingPushData(String link, String payload) {
try {
_pushClickHandler?.call(link, payload);
} catch (e) {
_logError('error when send pending push data: $e');
}
}

}
2 changes: 1 addition & 1 deletion mindbox_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mindbox_platform_interface
description: Mindbox platform interface.
version: 2.10.2-rc
version: 2.11.0
homepage: https://mindbox.cloud/
repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox_platform_interface

29 changes: 24 additions & 5 deletions to-local-dependensies.sh
Original file line number Diff line number Diff line change
@@ -4,12 +4,31 @@
common_yaml="mindbox/pubspec.yaml"
current_version=$(grep -E '^version: ' "$common_yaml" | cut -d':' -f2)

sed -i '' "s/ mindbox_android:.*/ mindbox_android:\n path: '..\/mindbox_android'/" $common_yaml
sed -i '' "s/ mindbox_ios:.*/ mindbox_ios:\n path: \"..\/mindbox_ios\"/" $common_yaml
sed -i '' "s/ mindbox_platform_interface:.*/ mindbox_platform_interface:\n path: \"..\/mindbox_platform_interface\" /" $common_yaml
# Update mindbox_android dependency
if ! grep -q "path: '../mindbox_android'" "$common_yaml"; then
sed -i '' "s/ mindbox_android:.*/ mindbox_android:\n path: '..\/mindbox_android'/" $common_yaml
fi

# Update mindbox_ios dependency
if ! grep -q "path: \"..\/mindbox_ios\"" "$common_yaml"; then
sed -i '' "s/ mindbox_ios:.*/ mindbox_ios:\n path: \"..\/mindbox_ios\"/" $common_yaml
fi

# Update mindbox_platform_interface dependency in common yaml
if ! grep -q "path: \"..\/mindbox_platform_interface\"" "$common_yaml"; then
sed -i '' "s/ mindbox_platform_interface:.*/ mindbox_platform_interface:\n path: \"..\/mindbox_platform_interface\" /" $common_yaml
fi

android_yaml="mindbox_android/pubspec.yaml"
sed -i '' "s/ mindbox_platform_interface:.*/ mindbox_platform_interface:\n path: \"..\/mindbox_platform_interface\" /" $android_yaml
# Update mindbox_platform_interface dependency in android yaml
if ! grep -q "path: \"..\/mindbox_platform_interface\"" "$android_yaml"; then
sed -i '' "s/ mindbox_platform_interface:.*/ mindbox_platform_interface:\n path: \"..\/mindbox_platform_interface\" /" $android_yaml
fi

ios_yaml="mindbox_ios/pubspec.yaml"
sed -i '' "s/ mindbox_platform_interface:.*/ mindbox_platform_interface:\n path: \"..\/mindbox_platform_interface\" /" $ios_yaml
# Update mindbox_platform_interface dependency in ios yaml
if ! grep -q "path: \"..\/mindbox_platform_interface\"" "$ios_yaml"; then
sed -i '' "s/ mindbox_platform_interface:.*/ mindbox_platform_interface:\n path: \"..\/mindbox_platform_interface\" /" $ios_yaml
fi

echo 'Local dependencies updated'

0 comments on commit 4306601

Please sign in to comment.