From 5f9357069091ac704574fb59e578f46a227e64ec Mon Sep 17 00:00:00 2001 From: sergeysozinov Date: Fri, 3 May 2024 16:21:19 +0300 Subject: [PATCH 1/7] MBX-3355: set method call handler on init --- .../lib/src/types/mindbox_method_handler.dart | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/mindbox_platform_interface/lib/src/types/mindbox_method_handler.dart b/mindbox_platform_interface/lib/src/types/mindbox_method_handler.dart index 4043635..052d284 100644 --- a/mindbox_platform_interface/lib/src/types/mindbox_method_handler.dart +++ b/mindbox_platform_interface/lib/src/types/mindbox_method_handler.dart @@ -59,6 +59,11 @@ class MindboxMethodHandler { 'before initialization.'); } await channel.invokeMethod('init', configuration.toMap()); + + if (!_methodHandlerSet) { + _setMethodCallHandler(); + } + for (final callbackMethod in _pendingCallbackMethods) { callbackMethod.callback( await channel.invokeMethod(callbackMethod.methodName) ?? 'null'); @@ -144,9 +149,6 @@ class MindboxMethodHandler { required PushClickHandler handler, }) { _pushClickHandler = handler; - if (!_methodHandlerSet) { - _setMethodCallHandler(); - } } /// Method for handling In-app click. @@ -154,9 +156,6 @@ class MindboxMethodHandler { required InAppClickHandler handler, }) { _inAppClickHandler = handler; - if (!_methodHandlerSet) { - _setMethodCallHandler(); - } registerInAppCallbacks(callbacks: [ CustomInAppCallback( _inAppClickHandler ?? (id, redirectUrl, payload) => {}, @@ -170,9 +169,6 @@ class MindboxMethodHandler { required InAppDismissedHandler handler, }) { _inAppDismissedHandler = handler; - if (!_methodHandlerSet) { - _setMethodCallHandler(); - } registerInAppCallbacks(callbacks: [ CustomInAppCallback( _inAppClickHandler ?? (id, redirectUrl, payload) => {}, @@ -291,22 +287,24 @@ class MindboxMethodHandler { void _setMethodCallHandler() { channel.setMethodCallHandler((call) { - if (call.method == 'pushClicked') { - if (call.arguments is List) { - _pushClickHandler?.call(call.arguments[0], call.arguments[1]); + switch (call.method) { + case 'pushClicked': + if (call.arguments is List) { + _pushClickHandler?.call(call.arguments[0], call.arguments[1]); + } + break; + case 'onInAppClick': + if (call.arguments is List) { + _inAppClickHandler?.call( + call.arguments[0], call.arguments[1], call.arguments[2]); + } + break; + case 'onInAppDismissed': + if (call.arguments is String) { + _inAppDismissedHandler?.call(call.arguments); + } + break; } - } - if (call.method == 'onInAppClick') { - if (call.arguments is List) { - _inAppClickHandler?.call( - call.arguments[0], call.arguments[1], call.arguments[2]); - } - } - if (call.method == 'onInAppDismissed') { - if (call.arguments is String) { - _inAppDismissedHandler?.call(call.arguments); - } - } return Future.value(true); }); _methodHandlerSet = true; From dd5f62a48dbcbe985ac24d5bdb08fad8e55e379a Mon Sep 17 00:00:00 2001 From: Dmitry Erofeev <56806136+kniksees@users.noreply.github.com> Date: Thu, 16 May 2024 14:54:02 +0300 Subject: [PATCH 2/7] MBX-3338: Full flutter example (#89) * MBX-3338-Example: remove old examples * MBX-3338-Example: add empty project * MBX-3338-Example: remove linux * MBX-3338-Example: remove macos * MBX-3338-Example: remove web * MBX-3338-Example: remove windows * MBX-3338: Full example flutter: flutter segment (#86) * MBX-3338-FullExampleFlutter-Flutter: flutter files * MBX-3338-FullExampleFlutter-Flutter: update flutter * MBX-3338-FullExampleFlutter-Flutter: update viewmodel * MBX-3338-FullExampleFlutter-Flutter: update readme * MBX-3338: Full example flutter: Android segment (#88) * MBX-3338-FullExampleFlutter-Android: android files * MBX-3338-FullExampleFlutter-Android: update android * MBX-3338-FullExampleFlutter-Android: update comments * MBX-3338-FullExampleFlutter-Android: update android * MBX-3338: Full example flutter: iOS segment (#87) * MBX-3338-FullExampleFlutter-iOS: iOS files * MBX-3338-FullExampleFlutter-iOS: add bg tasks * MBX-3338-FullExampleFlutter:add alert --- .../flutter_example}/.gitignore | 19 +- example/flutter_example/.metadata | 45 + example/flutter_example/README.md | 71 + .../flutter_example}/analysis_options.yaml | 3 +- .../flutter_example}/android/.gitignore | 0 .../flutter_example/android/app/build.gradle | 78 ++ .../android/app/src/debug/AndroidManifest.xml | 3 +- .../android/app/src/main/AndroidManifest.xml | 39 +- .../mindbox/flutter_example/MainActivity.kt | 5 + .../flutter_example/MainApplication.kt | 13 + .../MindboxFirebaseMessagingService.kt | 37 + .../MindboxHuaweiMessagingService.kt | 36 + .../res/drawable-v21/launch_background.xml | 0 .../main/res/drawable/launch_background.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 3 +- .../flutter_example}/android/build.gradle | 8 +- .../android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../flutter_example/android/settings.gradle | 27 + .../flutter_example}/ios/.gitignore | 1 + .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../ios/Flutter/Debug.xcconfig | 0 .../ios/Flutter/Release.xcconfig | 0 .../Info.plist | 22 + ...xNotificationContentExtension.entitlements | 10 + .../NotificationViewController.swift | 21 + .../Info.plist | 13 + ...xNotificationServiceExtension.entitlements | 10 + .../NotificationService.swift | 24 + .../flutter_example}/ios/Podfile | 32 +- example/flutter_example/ios/Podfile.lock | 58 + .../ios/Runner.xcodeproj/project.pbxproj | 1219 +++++++++++++++++ .../contents.xcworkspacedata | 0 .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../xcshareddata/WorkspaceSettings.xcsettings | 0 .../xcshareddata/xcschemes/Runner.xcscheme | 21 +- .../contents.xcworkspacedata | 0 .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../xcshareddata/WorkspaceSettings.xcsettings | 0 .../ios/Runner/AppDelegate.swift | 22 + .../AppIcon.appiconset/Contents.json | 0 .../Icon-App-1024x1024@1x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 0 -> 295 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 0 -> 406 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 0 -> 450 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 0 -> 282 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 0 -> 462 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 0 -> 704 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 0 -> 406 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 0 -> 586 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 0 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 0 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 0 -> 1674 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 0 -> 762 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 0 -> 1226 bytes .../Icon-App-83.5x83.5@2x.png | Bin 0 -> 1418 bytes .../LaunchImage.imageset/Contents.json | 0 .../LaunchImage.imageset/LaunchImage.png | Bin .../LaunchImage.imageset/LaunchImage@2x.png | Bin .../LaunchImage.imageset/LaunchImage@3x.png | Bin .../LaunchImage.imageset/README.md | 0 .../Runner/Base.lproj/LaunchScreen.storyboard | 0 .../ios/Runner/Base.lproj/Main.storyboard | 13 +- .../flutter_example}/ios/Runner/Info.plist | 26 +- .../ios/Runner/Runner-Bridging-Header.h | 0 .../ios/Runner/Runner.entitlements | 12 + .../ios/RunnerTests/RunnerTests.swift | 12 + .../flutter_example/lib/assets/MBColors.dart | 9 + example/flutter_example/lib/main.dart | 29 + example/flutter_example/lib/view/Example.dart | 17 + .../lib/view/main_page/main_page.dart | 78 ++ .../widgets/buttons_block/buttons_block.dart | 47 + .../buttons_block/buttons_block_line.dart | 56 + .../widgets/info_block/info_block.dart | 94 ++ .../widgets/info_block/ingo_block_line.dart | 57 + .../view/push_info_page/push_info_page.dart | 30 + .../push_info_page/widgets/info_block.dart | 60 + .../widgets/ingo_block_line.dart | 57 + .../lib/view_model/view_model.dart | 113 ++ example/flutter_example/pubspec.lock | 498 +++++++ example/flutter_example/pubspec.yaml | 25 + mindbox_android/example/.gitignore | 59 - mindbox_android/example/README.md | 16 - mindbox_android/example/analysis_options.yaml | 29 - .../example/android/app/build.gradle | 69 - .../mindbox_android_example/MainActivity.kt | 6 - .../example/android/settings.gradle | 11 - mindbox_android/example/lib/main.dart | 56 - mindbox_android/example/pubspec.yaml | 84 -- mindbox_ios/example/README.md | 16 - .../ios/Runner.xcodeproj/project.pbxproj | 554 -------- .../example/ios/Runner/AppDelegate.swift | 13 - .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 564 -> 0 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 1283 -> 0 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 1588 -> 0 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 1025 -> 0 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 1716 -> 0 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 1920 -> 0 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 1283 -> 0 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 1895 -> 0 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 2665 -> 0 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 2665 -> 0 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 3831 -> 0 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 1888 -> 0 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 3294 -> 0 bytes .../Icon-App-83.5x83.5@2x.png | Bin 3612 -> 0 bytes mindbox_ios/example/lib/main.dart | 57 - mindbox_ios/example/pubspec.yaml | 84 -- 115 files changed, 3027 insertions(+), 1114 deletions(-) rename {mindbox_ios/example => example/flutter_example}/.gitignore (72%) create mode 100644 example/flutter_example/.metadata create mode 100644 example/flutter_example/README.md rename {mindbox_ios/example => example/flutter_example}/analysis_options.yaml (93%) rename {mindbox_android/example => example/flutter_example}/android/.gitignore (100%) create mode 100644 example/flutter_example/android/app/build.gradle rename {mindbox_android/example => example/flutter_example}/android/app/src/debug/AndroidManifest.xml (58%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/AndroidManifest.xml (64%) create mode 100644 example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainActivity.kt create mode 100644 example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainApplication.kt create mode 100644 example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxFirebaseMessagingService.kt create mode 100644 example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxHuaweiMessagingService.kt rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/drawable-v21/launch_background.xml (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/drawable/launch_background.xml (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/values-night/styles.xml (94%) rename {mindbox_android/example => example/flutter_example}/android/app/src/main/res/values/styles.xml (94%) rename {mindbox_android/example => example/flutter_example}/android/app/src/profile/AndroidManifest.xml (58%) rename {mindbox_android/example => example/flutter_example}/android/build.gradle (67%) rename {mindbox_android/example => example/flutter_example}/android/gradle.properties (64%) rename {mindbox_android/example => example/flutter_example}/android/gradle/wrapper/gradle-wrapper.properties (92%) create mode 100644 example/flutter_example/android/settings.gradle rename {mindbox_ios/example => example/flutter_example}/ios/.gitignore (98%) rename {mindbox_ios/example => example/flutter_example}/ios/Flutter/AppFrameworkInfo.plist (96%) rename {mindbox_ios/example => example/flutter_example}/ios/Flutter/Debug.xcconfig (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Flutter/Release.xcconfig (100%) create mode 100644 example/flutter_example/ios/MindboxNotificationContentExtension/Info.plist create mode 100644 example/flutter_example/ios/MindboxNotificationContentExtension/MindboxNotificationContentExtension.entitlements create mode 100644 example/flutter_example/ios/MindboxNotificationContentExtension/NotificationViewController.swift create mode 100644 example/flutter_example/ios/MindboxNotificationServiceExtension/Info.plist create mode 100644 example/flutter_example/ios/MindboxNotificationServiceExtension/MindboxNotificationServiceExtension.entitlements create mode 100644 example/flutter_example/ios/MindboxNotificationServiceExtension/NotificationService.swift rename {mindbox_ios/example => example/flutter_example}/ios/Podfile (61%) create mode 100644 example/flutter_example/ios/Podfile.lock create mode 100644 example/flutter_example/ios/Runner.xcodeproj/project.pbxproj rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (86%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcworkspace/contents.xcworkspacedata (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings (100%) create mode 100644 example/flutter_example/ios/Runner/AppDelegate.swift rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png (100%) create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png create mode 100644 example/flutter_example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Base.lproj/LaunchScreen.storyboard (100%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Base.lproj/Main.storyboard (63%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Info.plist (74%) rename {mindbox_ios/example => example/flutter_example}/ios/Runner/Runner-Bridging-Header.h (100%) create mode 100644 example/flutter_example/ios/Runner/Runner.entitlements create mode 100644 example/flutter_example/ios/RunnerTests/RunnerTests.swift create mode 100644 example/flutter_example/lib/assets/MBColors.dart create mode 100644 example/flutter_example/lib/main.dart create mode 100644 example/flutter_example/lib/view/Example.dart create mode 100644 example/flutter_example/lib/view/main_page/main_page.dart create mode 100644 example/flutter_example/lib/view/main_page/widgets/buttons_block/buttons_block.dart create mode 100644 example/flutter_example/lib/view/main_page/widgets/buttons_block/buttons_block_line.dart create mode 100644 example/flutter_example/lib/view/main_page/widgets/info_block/info_block.dart create mode 100644 example/flutter_example/lib/view/main_page/widgets/info_block/ingo_block_line.dart create mode 100644 example/flutter_example/lib/view/push_info_page/push_info_page.dart create mode 100644 example/flutter_example/lib/view/push_info_page/widgets/info_block.dart create mode 100644 example/flutter_example/lib/view/push_info_page/widgets/ingo_block_line.dart create mode 100644 example/flutter_example/lib/view_model/view_model.dart create mode 100644 example/flutter_example/pubspec.lock create mode 100644 example/flutter_example/pubspec.yaml delete mode 100644 mindbox_android/example/.gitignore delete mode 100644 mindbox_android/example/README.md delete mode 100644 mindbox_android/example/analysis_options.yaml delete mode 100644 mindbox_android/example/android/app/build.gradle delete mode 100644 mindbox_android/example/android/app/src/main/kotlin/cloud/mindbox/mindbox_android_example/MainActivity.kt delete mode 100644 mindbox_android/example/android/settings.gradle delete mode 100644 mindbox_android/example/lib/main.dart delete mode 100644 mindbox_android/example/pubspec.yaml delete mode 100644 mindbox_ios/example/README.md delete mode 100644 mindbox_ios/example/ios/Runner.xcodeproj/project.pbxproj delete mode 100644 mindbox_ios/example/ios/Runner/AppDelegate.swift delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png delete mode 100644 mindbox_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png delete mode 100644 mindbox_ios/example/lib/main.dart delete mode 100644 mindbox_ios/example/pubspec.yaml diff --git a/mindbox_ios/example/.gitignore b/example/flutter_example/.gitignore similarity index 72% rename from mindbox_ios/example/.gitignore rename to example/flutter_example/.gitignore index daa55a8..3965723 100644 --- a/mindbox_ios/example/.gitignore +++ b/example/flutter_example/.gitignore @@ -8,17 +8,7 @@ .buildlog/ .history .svn/ -mindbox_ios_example.iml -pubspec.lock -.metadata -.packages -.flutter-plugins-dependencies -.flutter-plugins -ios/Podfile.lock -ios/Pods/ -android/gradlew -android/gradlew.bat -android/local.properties +migrate_working_dir/ # IntelliJ related *.iml @@ -37,14 +27,10 @@ android/local.properties .dart_tool/ .flutter-plugins .flutter-plugins-dependencies -.packages .pub-cache/ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols @@ -55,3 +41,6 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +/android/app/google-services.json +/android/app/agconnect-services.json \ No newline at end of file diff --git a/example/flutter_example/.metadata b/example/flutter_example/.metadata new file mode 100644 index 0000000..d2765fc --- /dev/null +++ b/example/flutter_example/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "54e66469a933b60ddf175f858f82eaeb97e48c8d" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: android + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: ios + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: linux + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: macos + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: web + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + - platform: windows + create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/flutter_example/README.md b/example/flutter_example/README.md new file mode 100644 index 0000000..4810d23 --- /dev/null +++ b/example/flutter_example/README.md @@ -0,0 +1,71 @@ +# Example app for Mindbox SDK for flutter + +This is an example of SDK [integration](https://developers.mindbox.ru/docs/flutter-sdk-integration) + +## Getting Started + +### IOS +1. Clone [flutter-sdk repository](https://github.com/mindbox-cloud/flutter-sdk). +2. Go to `flutter-sdk/example/flutter_example`. +3. From the terminal: + ``` + flutter pub get + ``` +4. Make sure you have CocoaPods installed or install it according to the instructions. +5. Go to `ios/Runner`. +6. Install pods: +``` +pod install +``` +7. Launch `Runner.xcworkspace` . +8. Launch app. + +Now you can test the in-app on the simulator. +In our admin panel there are already 3 ready-made in-apps that you can look at. +To run the application on a real device and try push notifications, follow the instructions below. + +9. Change [team](https://developers.mindbox.ru/docs/ios-get-keys) and bundle identifiers and App Group name for next targets: + - Runner + - MindboxNotificationServiceExtension + - MindboxNotificationContentExtension +10. [Configure your endpoints](https://developers.mindbox.ru/docs/add-ios-integration). +11. Change domain and endpoints in the `main.dart` to yours. + +### Android +1. Clone [flutter-sdk repository](https://github.com/mindbox-cloud/flutter-sdk). +2. Go to `flutter-sdk/example/flutter_example`. +3. From the terminal: + ``` + flutter pub get + ``` +4. Open `android` folder in Android Studio. +5. Change `namespace` and `applicationId` in `app/build.gradle` to yours. +6. Add `google-services.json` and `agconnect-services.json` to `android/app`. +- [Get google-services.json](https://developers.mindbox.ru/docs/firebase-get-keys) +- [Get agconnect-services.json](https://developers.mindbox.ru/docs/huawei-get-keys) +7. [Configure your endpoints](https://developers.mindbox.ru/docs/add-ios-integration). +8. Change domain and endpoints in the `main.dart` to yours. +8. Launch app. + +### SDK functionality testing +1. To check innap when opening: + - [Read this](https://help.mindbox.ru/docs/in-app-what-is). + - Open app. +2. To check the inapp anywhere in the application: + - [Read this](https://help.mindbox.ru/docs/in-app-location). + - Replace `operationSystemName` in `syncOperation` and `asyncOperation` in `view_model.dart`. + - Click to the button `Show in-app` opposite the selected operation. +3. To check push notifications: + - Read [iOS](https://developers.mindbox.ru/docs/ios-send-push-notifications-flutter). + - Read [android with Firebase](https://developers.mindbox.ru/docs/firebase-send-push-notifications-flutter). + - Read [android with Huawei](https://developers.mindbox.ru/docs/huawei-send-push-notifications-flutter). + - Send a notification from your account. +4. To check rich-push notifications: + - Read [iOS](https://developers.mindbox.ru/docs/ios-send-rich-push-flutter). + - Read [android with Firebase](https://developers.mindbox.ru/docs/firebase-send-push-notifications-flutter). + - Read [android with Huawei](https://developers.mindbox.ru/docs/huawei-send-push-notifications-flutter). + - Send a notification from your account. + +### Additionally + - Currently the In-App only comes once per session. + - There are comments and links in the flutter example code that can help you. diff --git a/mindbox_ios/example/analysis_options.yaml b/example/flutter_example/analysis_options.yaml similarity index 93% rename from mindbox_ios/example/analysis_options.yaml rename to example/flutter_example/analysis_options.yaml index 61b6c4d..0d29021 100644 --- a/mindbox_ios/example/analysis_options.yaml +++ b/example/flutter_example/analysis_options.yaml @@ -13,8 +13,7 @@ linter: # The lint rules applied to this project can be customized in the # section below to disable rules from the `package:flutter_lints/flutter.yaml` # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. + # and their documentation is published at https://dart.dev/lints. # # Instead of disabling a lint rule for the entire project in the # section below, it can also be suppressed for a single line of code diff --git a/mindbox_android/example/android/.gitignore b/example/flutter_example/android/.gitignore similarity index 100% rename from mindbox_android/example/android/.gitignore rename to example/flutter_example/android/.gitignore diff --git a/example/flutter_example/android/app/build.gradle b/example/flutter_example/android/app/build.gradle new file mode 100644 index 0000000..cadcaa3 --- /dev/null +++ b/example/flutter_example/android/app/build.gradle @@ -0,0 +1,78 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" + id 'com.google.gms.google-services' + id 'com.huawei.agconnect' +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "cloud.mindbox.flutter_example" + compileSdk flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + applicationId "cloud.mindbox.flutter_example" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + multiDexEnabled true + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } + buildToolsVersion '34.0.0' +} + +flutter { + source '../..' +} + +ext.mindbox_version = "2.8.5" + +dependencies { + implementation 'androidx.multidex:multidex:2.0.1' + //https://developers.mindbox.ru/docs/firebase-send-push-notifications-flutter + implementation "cloud.mindbox:mobile-sdk:$mindbox_version" + implementation "cloud.mindbox:mindbox-firebase:$mindbox_version" + implementation platform('com.google.firebase:firebase-bom:32.8.1') + implementation 'com.google.firebase:firebase-messaging:23.4.1' + //https://developers.mindbox.ru/docs/huawei-send-push-notifications-flutter + implementation "cloud.mindbox:mindbox-huawei:$mindbox_version" + implementation 'com.huawei.hms:push:6.11.0.300' +} \ No newline at end of file diff --git a/mindbox_android/example/android/app/src/debug/AndroidManifest.xml b/example/flutter_example/android/app/src/debug/AndroidManifest.xml similarity index 58% rename from mindbox_android/example/android/app/src/debug/AndroidManifest.xml rename to example/flutter_example/android/app/src/debug/AndroidManifest.xml index f880684..399f698 100644 --- a/mindbox_android/example/android/app/src/debug/AndroidManifest.xml +++ b/example/flutter_example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,6 @@ - diff --git a/mindbox_android/example/android/app/src/main/AndroidManifest.xml b/example/flutter_example/android/app/src/main/AndroidManifest.xml similarity index 64% rename from mindbox_android/example/android/app/src/main/AndroidManifest.xml rename to example/flutter_example/android/app/src/main/AndroidManifest.xml index d5a265f..b4d9445 100644 --- a/mindbox_android/example/android/app/src/main/AndroidManifest.xml +++ b/example/flutter_example/android/app/src/main/AndroidManifest.xml @@ -1,10 +1,28 @@ - + + + + + + + + + + + + + + - - @@ -37,5 +46,11 @@ + + + + + + diff --git a/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainActivity.kt b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainActivity.kt new file mode 100644 index 0000000..309e879 --- /dev/null +++ b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainActivity.kt @@ -0,0 +1,5 @@ +package cloud.mindbox.flutter_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainApplication.kt b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainApplication.kt new file mode 100644 index 0000000..09d37a9 --- /dev/null +++ b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainApplication.kt @@ -0,0 +1,13 @@ +package cloud.mindbox.flutter_example + +import android.app.Application +import cloud.mindbox.mobile_sdk.Mindbox +import cloud.mindbox.mindbox_firebase.MindboxFirebase +import cloud.mindbox.mindbox_huawei.MindboxHuawei + +class MainApplication : Application() { + override fun onCreate() { + super.onCreate() + Mindbox.initPushServices(applicationContext, listOf(MindboxFirebase, MindboxHuawei)) + } +} \ No newline at end of file diff --git a/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxFirebaseMessagingService.kt b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxFirebaseMessagingService.kt new file mode 100644 index 0000000..1e5a143 --- /dev/null +++ b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxFirebaseMessagingService.kt @@ -0,0 +1,37 @@ +package cloud.mindbox.flutter_example + +import cloud.mindbox.mobile_sdk.Mindbox +import com.google.firebase.messaging.* +import cloud.mindbox.mindbox_firebase.MindboxFirebase + +class MindboxFirebaseMessagingService: FirebaseMessagingService() { + override fun onNewToken(token: String) { + Mindbox.updatePushToken(applicationContext, token, MindboxFirebase) + super.onNewToken(token) + } + + override fun onMessageReceived(remoteMessage: RemoteMessage) { + super.onMessageReceived(remoteMessage) + val channelId = "default_channel_id" + val channelName = "default_channel_name" + val channelDescription = "default_channel_description" + val pushSmallIcon = android.R.drawable.ic_dialog_info + + + val messageWasHandled = Mindbox.handleRemoteMessage( + context = applicationContext, + message = remoteMessage, + activities = mapOf(), + channelId = channelId, + channelName = channelName, + pushSmallIcon = pushSmallIcon, + defaultActivity = MainActivity::class.java, + channelDescription = channelDescription + ) + + if (!messageWasHandled) { + //If the push notification was not from Mindbox or it contains incorrect data, then you can write a fallback to process it + } + } + +} \ No newline at end of file diff --git a/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxHuaweiMessagingService.kt b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxHuaweiMessagingService.kt new file mode 100644 index 0000000..bf477d5 --- /dev/null +++ b/example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxHuaweiMessagingService.kt @@ -0,0 +1,36 @@ +package cloud.mindbox.flutter_example + +import cloud.mindbox.mobile_sdk.Mindbox +import com.huawei.hms.push.* +import cloud.mindbox.mindbox_huawei.MindboxHuawei + +class MindboxHuaweiMessagingService: HmsMessageService() { + override fun onNewToken(token: String) { + super.onNewToken(token) + Mindbox.updatePushToken(applicationContext, token, MindboxHuawei) + } + + override fun onMessageReceived(remoteMessage: RemoteMessage) { + super.onMessageReceived(remoteMessage) + val channelId = "default_channel_id" + val channelName = "default_channel_name" + val channelDescription = "default_channel_description" + val pushSmallIcon = android.R.drawable.ic_dialog_info + + val messageWasHandled = Mindbox.handleRemoteMessage( + context = applicationContext, + message = remoteMessage, + activities = mapOf(), + channelId = channelId, + channelName = channelName, + pushSmallIcon = pushSmallIcon, + defaultActivity = MainActivity::class.java, + channelDescription = channelDescription + ) + + if (!messageWasHandled) { + //If the push notification was not from Mindbox or it contains incorrect data, then you can write a fallback to process it + } + + } +} \ No newline at end of file diff --git a/mindbox_android/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/flutter_example/android/app/src/main/res/drawable-v21/launch_background.xml similarity index 100% rename from mindbox_android/example/android/app/src/main/res/drawable-v21/launch_background.xml rename to example/flutter_example/android/app/src/main/res/drawable-v21/launch_background.xml diff --git a/mindbox_android/example/android/app/src/main/res/drawable/launch_background.xml b/example/flutter_example/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from mindbox_android/example/android/app/src/main/res/drawable/launch_background.xml rename to example/flutter_example/android/app/src/main/res/drawable/launch_background.xml diff --git a/mindbox_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/flutter_example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from mindbox_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to example/flutter_example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/mindbox_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/flutter_example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from mindbox_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to example/flutter_example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/mindbox_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/flutter_example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from mindbox_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to example/flutter_example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/mindbox_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/flutter_example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from mindbox_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to example/flutter_example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/mindbox_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/flutter_example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from mindbox_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to example/flutter_example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/mindbox_android/example/android/app/src/main/res/values-night/styles.xml b/example/flutter_example/android/app/src/main/res/values-night/styles.xml similarity index 94% rename from mindbox_android/example/android/app/src/main/res/values-night/styles.xml rename to example/flutter_example/android/app/src/main/res/values-night/styles.xml index 449a9f9..06952be 100644 --- a/mindbox_android/example/android/app/src/main/res/values-night/styles.xml +++ b/example/flutter_example/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@