diff --git a/.github/workflows/analyze_and_test.yml b/.github/workflows/analyze_and_test.yml index f07651f..c8bfa00 100644 --- a/.github/workflows/analyze_and_test.yml +++ b/.github/workflows/analyze_and_test.yml @@ -1,9 +1,20 @@ -name: analyze_and_test +name: Analyzes and Tests on: + push: + branches: + - develop + - mission/* pull_request: - branches: [ develop ] + types: + - opened + - reopened + - synchronize workflow_call: + inputs: + branch: + required: true + type: string jobs: platform_interface_flutter_test: @@ -11,6 +22,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch || github.head_ref }} - uses: actions/setup-java@v1 with: java-version: "12.x" @@ -29,6 +42,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch || github.head_ref }} - uses: actions/setup-java@v1 with: java-version: "12.x" @@ -50,6 +65,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch || github.head_ref }} - uses: actions/setup-java@v1 with: java-version: "12.x" @@ -71,6 +88,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch || github.head_ref }} - uses: actions/setup-java@v1 with: java-version: "12.x" @@ -86,6 +105,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch || github.head_ref }} - uses: actions/setup-java@v1 with: java-version: "12.x" @@ -125,4 +146,3 @@ jobs: - run: cd mindbox && flutter pub get - run: cd mindbox && flutter analyze - run: cd mindbox && flutter test - diff --git a/.github/workflows/distribute-develop-mission.yml b/.github/workflows/distribute-develop-mission.yml new file mode 100644 index 0000000..ad456db --- /dev/null +++ b/.github/workflows/distribute-develop-mission.yml @@ -0,0 +1,17 @@ +name: Distribute PushOk (Develop / Mission PR Merge) + +on: + pull_request: + branches: + - develop + - mission/* + types: + - closed + +jobs: + call-reusable: + if: ${{ github.event.pull_request.merged == true }} + uses: ./.github/workflows/distribute-reusable.yml + with: + branch: ${{ github.base_ref }} + secrets: inherit diff --git a/.github/workflows/distribute-manual.yml b/.github/workflows/distribute-manual.yml new file mode 100644 index 0000000..8c21bc7 --- /dev/null +++ b/.github/workflows/distribute-manual.yml @@ -0,0 +1,11 @@ +name: Distribute PushOk (manual) + +on: + workflow_dispatch: + +jobs: + call-reusable: + uses: ./.github/workflows/distribute-reusable.yml + with: + branch: ${{ github.ref_name }} + secrets: inherit diff --git a/.github/workflows/distribute-release-support-mission.yml b/.github/workflows/distribute-release-support-mission.yml new file mode 100644 index 0000000..06ffa4c --- /dev/null +++ b/.github/workflows/distribute-release-support-mission.yml @@ -0,0 +1,19 @@ +name: Distribute PushOk (Release / Support / Mission PRs) + +on: + pull_request: + branches: + - master + - support/* + - mission/* + types: + - opened + - synchronize + +jobs: + call-reusable: + if: ${{ startsWith(github.event.pull_request.head.ref, 'release/') }} + uses: ./.github/workflows/distribute-reusable.yml + with: + branch: ${{ github.event.pull_request.head.ref }} + secrets: inherit diff --git a/.github/workflows/trigger-build-app.yml b/.github/workflows/distribute-reusable.yml similarity index 52% rename from .github/workflows/trigger-build-app.yml rename to .github/workflows/distribute-reusable.yml index e54e7ea..310feae 100644 --- a/.github/workflows/trigger-build-app.yml +++ b/.github/workflows/distribute-reusable.yml @@ -1,19 +1,20 @@ -name: Build application after merge +name: Distribute PushOk - Reusable on: - pull_request: - types: [closed] - branches: - - 'feature/*' - - 'develop' + workflow_call: + inputs: + branch: + required: true + type: string jobs: trigger: runs-on: macos-latest - if: github.event.pull_request.merged == true steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} - name: Get last 3 commit messages run: | @@ -23,7 +24,7 @@ jobs: - name: Trigger build workflow in flutter-app repo run: | curl --location 'https://mindbox.gitlab.yandexcloud.net/api/v4/projects/1089/trigger/pipeline' \ - --form 'token="${{ secrets.GITLAB_TRIGGER_TOKEN }}"' \ - --form 'ref="develop"' \ - --form "variables[INPUT_BRANCH]=\"${{ github.head_ref }}\"" \ - --form "variables[INPUT_COMMITS]=\"${{ env.commits }}\"" + --form "token=${{ secrets.GITLAB_TRIGGER_TOKEN }}" \ + --form "ref=develop" \ + --form "variables[INPUT_BRANCH]=${{ inputs.branch }}" \ + --form "variables[INPUT_COMMITS]=${{ env.commits }}" diff --git a/.github/workflows/manual-prepare_release_branch.yml b/.github/workflows/manual-prepare_release_branch.yml new file mode 100644 index 0000000..9994bb0 --- /dev/null +++ b/.github/workflows/manual-prepare_release_branch.yml @@ -0,0 +1,245 @@ +name: "Manual Release Prep: Branch & Version Bump" + +on: + workflow_dispatch: + inputs: + release_version: + description: 'Cross-platform release version (e.g. 1.2.3 or 1.2.3-rc)' + required: true + android_sdk_version: + description: 'Native Android SDK version (optional, defaults to cross-platform version)' + required: false + default: '' + ios_sdk_version: + description: 'Native iOS SDK version (optional, defaults to cross-platform version)' + required: false + default: '' + source_branch: + description: 'Create branch from' + required: true + default: 'develop' + target_branch: + description: 'Pull Request to' + required: true + default: 'master' + +jobs: + validate-input: + name: Validate versions format + runs-on: ubuntu-latest + steps: + - name: Check release_version matches semver + run: | + V=${{ github.event.inputs.release_version }} + echo "Input release_version=$V" + if ! [[ "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then + echo "❌ release_version must be X.Y.Z or X.Y.Z-rc" + exit 1 + fi + - name: Validate Android SDK version if provided + if: ${{ github.event.inputs.android_sdk_version != '' }} + run: | + A=${{ github.event.inputs.android_sdk_version }} + echo "Input android_sdk_version=$A" + if ! [[ "$A" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then + echo "❌ android_sdk_version must be X.Y.Z or X.Y.Z-rc" + exit 1 + fi + - name: Validate iOS SDK version if provided + if: ${{ github.event.inputs.ios_sdk_version != '' }} + run: | + I=${{ github.event.inputs.ios_sdk_version }} + echo "Input ios_sdk_version=$I" + if ! [[ "$I" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then + echo "❌ ios_sdk_version must be X.Y.Z or X.Y.Z-rc" + exit 1 + fi + + validate-branches: + name: Validate branch names exist + runs-on: ubuntu-latest + needs: validate-input + steps: + - name: Checkout minimal repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check source branch + run: | + SRC=${{ github.event.inputs.source_branch }} + echo "Source branch: $SRC" + if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then + echo "❌ source_branch '$SRC' does not exist" + exit 1 + fi + - name: Check target branch + run: | + DST=${{ github.event.inputs.target_branch }} + echo "Target branch: $DST" + if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then + echo "❌ target_branch '$DST' does not exist" + exit 1 + fi + + bump_and_branch: + name: Create release branch & bump versions + runs-on: ubuntu-latest + needs: validate-branches + outputs: + release_branch: ${{ steps.bump.outputs.release_branch }} + steps: + - name: Checkout source branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.source_branch }} + fetch-depth: 0 + + - name: Configure Git identity for GitHub Action Bot + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Create branch and update versions + id: bump + run: | + set -euo pipefail + VERSION="${{ github.event.inputs.release_version }}" + AND_VER="${{ github.event.inputs.android_sdk_version }}" + IO_VER="${{ github.event.inputs.ios_sdk_version }}" + SRC="${{ github.event.inputs.source_branch }}" + REL="release/$VERSION" + + echo "Parameters before fallback: AND_VER=$AND_VER, IO_VER=$IO_VER" + # fallback to cross-platform version + [ -z "$AND_VER" ] && AND_VER="$VERSION" + [ -z "$IO_VER" ] && IO_VER="$VERSION" + echo "Using versions: Flutter=$VERSION, Android=$AND_VER, iOS=$IO_VER" + + echo "→ Branching from $SRC into $REL" + git checkout -b "$REL" + + echo "→ Current pubspec versions before bump:" + grep '^version:' mindbox/pubspec.yaml || true + grep '^version:' mindbox_android/pubspec.yaml || true + grep '^version:' mindbox_ios/pubspec.yaml || true + grep '^version:' mindbox_platform_interface/pubspec.yaml || true + + echo "→ Updating pubspec versions" + for yaml in \ + mindbox/pubspec.yaml \ + mindbox_android/pubspec.yaml \ + mindbox_ios/pubspec.yaml \ + mindbox_platform_interface/pubspec.yaml; do + + # bump version of the package + sed -i "s/^version:.*/version: $VERSION/" "$yaml" + + # raise all flutter dependencies in the root pubspec + if [ "$yaml" = "mindbox/pubspec.yaml" ]; then + sed -i "s/^ mindbox_android:.*/ mindbox_android: ^$VERSION/" "$yaml" + sed -i "s/^ mindbox_ios:.*/ mindbox_ios: ^$VERSION/" "$yaml" + sed -i "s/^ mindbox_platform_interface:.*/ mindbox_platform_interface: ^$VERSION/" "$yaml" + fi + + # in the Android plugin also update platform_interface + if [ "$yaml" = "mindbox_android/pubspec.yaml" ]; then + sed -i "s/^ mindbox_platform_interface:.*/ mindbox_platform_interface: ^$VERSION/" "$yaml" + fi + + # in iOS plugin: only platform_interface + if [ "$yaml" = "mindbox_ios/pubspec.yaml" ]; then + sed -i "s/^ mindbox_platform_interface:.*/ mindbox_platform_interface: ^$VERSION/" "$yaml" + fi + + done + + echo "→ Bumping Android native SDK in build.gradle" + echo " Before:" && grep "cloud.mindbox:mobile-sdk" mindbox_android/android/build.gradle || true + sed -i "s/cloud.mindbox:mobile-sdk:.*/cloud.mindbox:mobile-sdk:$AND_VER'/" mindbox_android/android/build.gradle + echo " After:" && grep "cloud.mindbox:mobile-sdk" mindbox_android/android/build.gradle || true + + echo "→ Bumping iOS native SDK in podspec" + echo " Before s.version:" && grep -E "s\.version" mindbox_ios/ios/mindbox_ios.podspec || true + sed -i -E "s/(s\.version *= *')[^']+(')/\1$IO_VER\2/" mindbox_ios/ios/mindbox_ios.podspec + echo " After s.version:" && grep -E "s\.version" mindbox_ios/ios/mindbox_ios.podspec || true + + echo " Before Mindbox dependency:" && grep "s.dependency 'Mindbox'," mindbox_ios/ios/mindbox_ios.podspec || true + sed -i -E "s/(s\.dependency 'Mindbox', *')[^']+(')/\1$IO_VER\2/" mindbox_ios/ios/mindbox_ios.podspec + echo " After Mindbox dependency:" && grep "s.dependency 'Mindbox'," mindbox_ios/ios/mindbox_ios.podspec || true + + echo " Before Notifications dep:" && grep "MindboxNotifications" mindbox_ios/ios/mindbox_ios.podspec || true + sed -i -E "s/(s\.dependency 'MindboxNotifications', *')[^']+(')/\1$IO_VER\2/" mindbox_ios/ios/mindbox_ios.podspec + echo " After Notifications dep:" && grep "MindboxNotifications" mindbox_ios/ios/mindbox_ios.podspec || true + + echo "→ Now inspect pubspec.yaml versions:" + echo " mindbox/pubspec.yaml:" && grep "^version\|mindbox_" mindbox/pubspec.yaml || true + echo " mindbox_android/pubspec.yaml:" && grep "^version\|platform_interface" mindbox_android/pubspec.yaml || true + echo " mindbox_ios/pubspec.yaml:" && grep "^version\|platform_interface" mindbox_ios/pubspec.yaml || true + echo " mindbox_platform_interface/pubspec.yaml:" && grep "^version" mindbox_platform_interface/pubspec.yaml || true + + echo "→ Generating changelogs" + # mindbox: both native + file="mindbox/CHANGELOG.md" + echo -e "## $VERSION\n\n* Upgrade native Android SDK dependency to v$AND_VER.\n* Upgrade native iOS SDK dependency to v$IO_VER.\n\n$(cat $file)" > "$file" + git add "$file" + + # mindbox_android: only Android + file="mindbox_android/CHANGELOG.md" + echo -e "## $VERSION\n\n* Upgrade native Android SDK dependency to v$AND_VER.\n\n$(cat $file)" > "$file" + git add "$file" + + # mindbox_ios: only iOS + file="mindbox_ios/CHANGELOG.md" + echo -e "## $VERSION\n\n* Upgrade native iOS SDK dependency to v$IO_VER.\n\n$(cat $file)" > "$file" + git add "$file" + + # mindbox_platform_interface: both native + file="mindbox_platform_interface/CHANGELOG.md" + echo -e "## $VERSION\n\n* Upgrade native Android SDK dependency to v$AND_VER.\n* Upgrade native iOS SDK dependency to v$IO_VER.\n\n$(cat $file)" > "$file" + git add "$file" + + echo "→ Commit diff summary:" + git diff --stat + + echo "→ Staging all bumped files" + git add mindbox/pubspec.yaml \ + mindbox_android/pubspec.yaml \ + mindbox_ios/pubspec.yaml \ + mindbox_platform_interface/pubspec.yaml \ + mindbox_android/android/build.gradle \ + mindbox_ios/ios/mindbox_ios.podspec + + git commit -m "Bump SDK versions: Flutter=$VERSION, Android=$AND_VER, iOS=$IO_VER" + echo "release_branch=$REL" >> $GITHUB_OUTPUT + + - name: Push release branch + run: git push --set-upstream origin ${{ steps.bump.outputs.release_branch }} + + create_pull_request: + name: Create Pull Request + runs-on: ubuntu-latest + needs: bump_and_branch + steps: + - name: Create PR via GitHub CLI + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + SRC: ${{ needs.bump_and_branch.outputs.release_branch }} + DST: ${{ github.event.inputs.target_branch }} + REPO: ${{ github.repository }} + run: | + AND_VER=${{ github.event.inputs.android_sdk_version }} + IO_VER=${{ github.event.inputs.ios_sdk_version }} + [ -z "$AND_VER" ] && AND_VER="${{ github.event.inputs.release_version }}" + [ -z "$IO_VER" ] && IO_VER="${{ github.event.inputs.release_version }}" + + BODY=$( + printf 'Automated PR: merge `%s` into `%s`\n\n**Versions:**\n- Flutter SDK: `%s`\n- Android SDK: `%s`\n- iOS SDK: `%s`' \ + "$SRC" "$DST" "${{ github.event.inputs.release_version }}" "$AND_VER" "$IO_VER" + ) + + gh pr create \ + --repo "$REPO" \ + --base "$DST" \ + --head "$SRC" \ + --title "Release ${{ github.event.inputs.release_version }}" \ + --body "$BODY" diff --git a/.github/workflows/pr-description-validate.yml b/.github/workflows/pr-description-validate.yml index ee497c9..af3a1f3 100644 --- a/.github/workflows/pr-description-validate.yml +++ b/.github/workflows/pr-description-validate.yml @@ -9,7 +9,7 @@ on: jobs: check-description: runs-on: ubuntu-latest - + if: ${{ github.event_name == 'pull_request' || github.event.issue.pull_request }} steps: - name: Check out the repository uses: actions/checkout@v4 diff --git a/.github/workflows/publish-from-master-or-support.yml b/.github/workflows/publish-from-master-or-support.yml new file mode 100644 index 0000000..adebf2e --- /dev/null +++ b/.github/workflows/publish-from-master-or-support.yml @@ -0,0 +1,16 @@ +name: SDK publish from master or support branch + +on: + pull_request: + types: [closed] + branches: + - 'master' + - 'support/*' + +jobs: + call-reusable: + if: ${{ github.event.pull_request.merged == true }} + uses: ./.github/workflows/publish-reusable.yml + with: + branch: ${{ github.base_ref }} + secrets: inherit diff --git a/.github/workflows/publish-manual.yml b/.github/workflows/publish-manual.yml new file mode 100644 index 0000000..c4f2669 --- /dev/null +++ b/.github/workflows/publish-manual.yml @@ -0,0 +1,22 @@ +name: SDK publish RC manual + +on: + workflow_dispatch: + +jobs: + check-branch: + runs-on: ubuntu-latest + steps: + - name: Check if branch matches pattern + run: | + if ! echo "${{ github.ref_name }}" | grep -q "release/.*-rc"; then + echo "Branch name must match pattern 'release/*-rc' (e.g. release/2.13.2-rc)" + exit 1 + fi + + call-publish-reusable: + needs: check-branch + uses: ./.github/workflows/publish-reusable.yml + with: + branch: ${{ github.ref_name }} + secrets: inherit diff --git a/.github/workflows/publish.yml b/.github/workflows/publish-reusable.yml similarity index 62% rename from .github/workflows/publish.yml rename to .github/workflows/publish-reusable.yml index f9eba36..e706114 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish-reusable.yml @@ -1,26 +1,30 @@ -name: publish +name: SDK publish on: - pull_request: - types: [ closed ] - branches: - - master + workflow_call: + inputs: + branch: + required: true + type: string jobs: - analyze_and_test: - name: Analyze code and run tests before publishing - uses: ./.github/workflows/analyze_and_test.yml - - platform_interface_publish: + analyze_and_test: + name: Analyze code and run tests before publishing + uses: ./.github/workflows/analyze_and_test.yml + with: + branch: ${{ inputs.branch }} + secrets: inherit + + platform_interface_publish: needs: [analyze_and_test] - if: github.event.pull_request.merged timeout-minutes: 4 runs-on: ubuntu-latest name: mindbox_platform_interface publishing steps: - - uses: actions/checkout@v2.3.3 + - uses: actions/checkout@v4 with: fetch-depth: 2 + ref: ${{ inputs.branch }} - name: Check package Pubspec id: pubspec run: | @@ -51,10 +55,16 @@ jobs: release_name: mindbox_platform_interface v${{ env.VERSION }} draft: false prerelease: false + + waiting-while-platform-interface-publish: + needs: [platform_interface_publish] + runs-on: ubuntu-latest + steps: + - name: Delay for 1 minutes + run: sleep 60 - native_components_publish: - needs: [analyze_and_test,platform_interface_publish] - if: github.event.pull_request.merged + native_components_publish: + needs: [analyze_and_test, platform_interface_publish, waiting-while-platform-interface-publish] timeout-minutes: 4 runs-on: ubuntu-latest name: ${{ matrix.package }} publishing @@ -66,9 +76,10 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v2.3.3 + - uses: actions/checkout@v4 with: fetch-depth: 2 + ref: ${{ inputs.branch }} - name: Check package Pubspec id: pubspec run: | @@ -100,16 +111,23 @@ jobs: draft: false prerelease: false - plugin_publish: - needs: [analyze_and_test,platform_interface_publish, native_components_publish] - if: github.event.pull_request.merged + waiting-while-native_components_publish: + needs: [native_components_publish] + runs-on: ubuntu-latest + steps: + - name: Delay for 1 minutes + run: sleep 60 + + plugin_publish: + needs: [analyze_and_test, platform_interface_publish, native_components_publish, waiting-while-native_components_publish] timeout-minutes: 4 runs-on: ubuntu-latest name: mindbox publishing steps: - - uses: actions/checkout@v2.3.3 + - uses: actions/checkout@v4 with: fetch-depth: 2 + ref: ${{ inputs.branch }} - name: Check package Pubspec id: pubspec run: | @@ -141,3 +159,41 @@ jobs: release_name: mindbox v${{ env.VERSION }} draft: false prerelease: false + + merge: + needs: [plugin_publish] + if: | + startsWith(github.head_ref, 'release') && + github.base_ref == 'master' + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + steps: + - name: Checkout develop branch + uses: actions/checkout@v4 + with: + ref: develop + - name: Create Pull Request + run: gh pr create --base develop --head master --title "Merge 'master' into 'develop' after release" --body "Automated Pull Request to merge 'master' into 'develop' after release" + - name: Merge Pull Request + run: | + pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') + gh pr merge $pr_number --merge --auto + + message-to-loop-if-success: + needs: [ merge ] + runs-on: ubuntu-latest + steps: + - name: Send message to LOOP + env: + LOOP_NOTIFICATION_WEBHOOK_URL: ${{ secrets.LOOP_NOTIFICATION_WEBHOOK_URL }} + VERSION: ${{ inputs.branch }} + run: | + MESSAGE=$(cat <> $GITHUB_ENV + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + - name: Compare versions + uses: jackbilestech/semver-compare@1.0.4 + with: + head: ${{ env.RELEASE_VERSION }} + base: ${{ env.MASTER_VERSION }} + operator: '>' diff --git a/example/flutter_example/lib/view_model/view_model.dart b/example/flutter_example/lib/view_model/view_model.dart index 9922ebe..6b0afc6 100644 --- a/example/flutter_example/lib/view_model/view_model.dart +++ b/example/flutter_example/lib/view_model/view_model.dart @@ -67,12 +67,12 @@ class ViewModel { } static Future requestPermissions() async { - Permission.notification.isDenied.then((bool isGranted) async { - final PermissionStatus status = await Permission.notification.request(); - - Mindbox.instance - .updateNotificationPermissionStatus(granted: status.isGranted); - }); + var status = await Permission.notification.status; + if (!status.isGranted) { + status = await Permission.notification.request(); + Mindbox.instance.updateNotificationPermissionStatus( + granted: status.isGranted); + } } //https://developers.mindbox.ru/docs/in-app diff --git a/mindbox/CHANGELOG.md b/mindbox/CHANGELOG.md index dd6b3b2..81b0ce9 100644 --- a/mindbox/CHANGELOG.md +++ b/mindbox/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.13.4 + +* Upgrade native Android SDK dependency to v2.13.4. +* Upgrade native iOS SDK dependency to v2.13.4. + ## 2.13.2-rc * Upgrade native Android SDK dependency to v2.13.2-rc. diff --git a/mindbox/pubspec.yaml b/mindbox/pubspec.yaml index 9d3eb21..390d63f 100644 --- a/mindbox/pubspec.yaml +++ b/mindbox/pubspec.yaml @@ -1,6 +1,6 @@ name: mindbox description: Flutter Mindbox SDK. Plugin wrapper over of Mindbox iOS/Android SDK. -version: 2.13.2-rc +version: 2.13.4 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.13.2-rc - mindbox_ios: ^2.13.2-rc - mindbox_platform_interface: ^2.13.2-rc + mindbox_android: ^2.13.4 + mindbox_ios: ^2.13.4 + mindbox_platform_interface: ^2.13.4 dev_dependencies: flutter_test: diff --git a/mindbox_android/CHANGELOG.md b/mindbox_android/CHANGELOG.md index 21f7a99..4fd70a3 100644 --- a/mindbox_android/CHANGELOG.md +++ b/mindbox_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.13.4 + +* Upgrade native Android SDK dependency to v2.13.4. + ## 2.13.2-rc * Upgrade native Android SDK dependency to v2.13.2-rc. diff --git a/mindbox_android/android/build.gradle b/mindbox_android/android/build.gradle index a562475..2617a13 100644 --- a/mindbox_android/android/build.gradle +++ b/mindbox_android/android/build.gradle @@ -50,5 +50,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - api 'cloud.mindbox:mobile-sdk:2.13.2-rc' + api 'cloud.mindbox:mobile-sdk:2.13.4' } diff --git a/mindbox_android/pubspec.yaml b/mindbox_android/pubspec.yaml index fd2c637..c9bfb4b 100644 --- a/mindbox_android/pubspec.yaml +++ b/mindbox_android/pubspec.yaml @@ -1,6 +1,6 @@ name: mindbox_android description: The implementation of 'mindbox' plugin for the Android platform. -version: 2.13.2-rc +version: 2.13.4 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.13.2-rc + mindbox_platform_interface: ^2.13.4 dev_dependencies: flutter_test: diff --git a/mindbox_ios/CHANGELOG.md b/mindbox_ios/CHANGELOG.md index 357f44f..6fabae6 100644 --- a/mindbox_ios/CHANGELOG.md +++ b/mindbox_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.13.4 + +* Upgrade native iOS SDK dependency to v2.13.4. + ## 2.13.2-rc * Upgrade native iOS SDK dependency to v2.13.2-rc. diff --git a/mindbox_ios/ios/mindbox_ios.podspec b/mindbox_ios/ios/mindbox_ios.podspec index 04e9b37..6ad908e 100644 --- a/mindbox_ios/ios/mindbox_ios.podspec +++ b/mindbox_ios/ios/mindbox_ios.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'mindbox_ios' - s.version = '2.13.2-rc' + s.version = '2.13.4' s.summary = 'Mindbox Flutter SDK' s.description = <<-DESC The implementation of 'mindbox' plugin for the iOS platform @@ -15,8 +15,8 @@ The implementation of 'mindbox' plugin for the iOS platform s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'Mindbox', '2.13.2-rc' - s.dependency 'MindboxNotifications', '2.13.2-rc' + s.dependency 'Mindbox', '2.13.4' + s.dependency 'MindboxNotifications', '2.13.4' s.platform = :ios, '12.0' # Flutter.framework does not contain a i386 slice. diff --git a/mindbox_ios/pubspec.yaml b/mindbox_ios/pubspec.yaml index b31cfc0..348f4bf 100644 --- a/mindbox_ios/pubspec.yaml +++ b/mindbox_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: mindbox_ios description: The implementation of 'mindbox' plugin for the iOS platform. -version: 2.13.2-rc +version: 2.13.4 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.13.2-rc + mindbox_platform_interface: ^2.13.4 dev_dependencies: flutter_test: diff --git a/mindbox_platform_interface/CHANGELOG.md b/mindbox_platform_interface/CHANGELOG.md index bb31a2e..2303b5a 100644 --- a/mindbox_platform_interface/CHANGELOG.md +++ b/mindbox_platform_interface/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.13.4 + +* Upgrade native Android SDK dependency to v2.13.4. +* Upgrade native iOS SDK dependency to v2.13.4. + ## 2.13.2-rc * Upgrade native Android SDK dependency to v2.13.2-rc. 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 cd1ec62..14e2c6a 100644 --- a/mindbox_platform_interface/lib/src/types/mindbox_method_handler.dart +++ b/mindbox_platform_interface/lib/src/types/mindbox_method_handler.dart @@ -49,6 +49,7 @@ class MindboxMethodHandler { InAppClickHandler? _inAppClickHandler; InAppDismissedHandler? _inAppDismissedHandler; bool _methodHandlerSet = false; + Future _initFuture = Future.value(); /// Returns native SDK version. Future get nativeSdkVersion async => @@ -59,6 +60,13 @@ class MindboxMethodHandler { /// You can call this method multiple times to set new configuration params. /// Read more about [Configuration] parameter. Future init({required Configuration configuration}) async { + _initFuture = _initFuture.then((_) async { + await _init(configuration: configuration); + }); + await _initFuture; + } + + Future _init({required Configuration configuration}) async { try { //ignore: unnecessary_null_comparison if (ServicesBinding.instance == null) { @@ -73,11 +81,15 @@ class MindboxMethodHandler { _setMethodCallHandler(); } - for (final callbackMethod in _pendingCallbackMethods) { + final pendingCallbackMethodsCopy = + List<_PendingCallbackMethod>.from(_pendingCallbackMethods); + for (final callbackMethod in pendingCallbackMethodsCopy) { callbackMethod.callback( await channel.invokeMethod(callbackMethod.methodName) ?? 'null'); } - for (final operation in _pendingOperations) { + final pendingOperationsCopy = + List<_PendingOperations>.from(_pendingOperations); + for (final operation in pendingOperationsCopy) { channel.invokeMethod(operation.methodName, operation.parameters).then( (result) { if (operation.successCallback != null) { @@ -92,8 +104,8 @@ class MindboxMethodHandler { } _pendingCallbackMethods.clear(); _pendingOperations.clear(); - _initialized = true; _logInfo('Init in Flutter'); + _initialized = true; } on PlatformException catch (e) { throw MindboxInitializeError( message: e.message ?? '', data: e.details ?? ''); @@ -102,6 +114,7 @@ class MindboxMethodHandler { /// Returns device UUID to callback. void getDeviceUUID({required Function(String uuid) callback}) async { + await _initFuture; if (_initialized) { callback(await channel.invokeMethod('getDeviceUUID')); } else { @@ -112,6 +125,7 @@ class MindboxMethodHandler { /// Returns token to callback. void getToken({required Function(String token) callback}) async { + await _initFuture; if (_initialized) { callback(await channel.invokeMethod('getToken') ?? 'null'); } else { @@ -122,6 +136,7 @@ class MindboxMethodHandler { /// Returns token to callback. void getTokens({required Function(String token) callback}) async { + await _initFuture; if (_initialized) { callback(await channel.invokeMethod('getTokens') ?? 'null'); } else { @@ -143,25 +158,25 @@ class MindboxMethodHandler { /// Method for registers a list of InAppCallback instances to handle clicks /// and dismiss in in-apps. void registerInAppCallbacks({required List callbacks}) async { - final List types = []; - bool custom = false; - for (var element in callbacks) { - if (element is CustomInAppCallback) { - _inAppClickHandler = element.clickHandler; - _inAppDismissedHandler = element.dismissedHandler; - custom = true; - } - types.add(element.type); - } - - if (custom == false - && (_inAppClickHandler != null || _inAppDismissedHandler != null)) { - types.add('CustomInAppCallback'); - } - - if (types.isNotEmpty) { - await channel.invokeMethod('registerInAppCallbacks', types); - } + final List types = []; + bool custom = false; + for (var element in callbacks) { + if (element is CustomInAppCallback) { + _inAppClickHandler = element.clickHandler; + _inAppDismissedHandler = element.dismissedHandler; + custom = true; + } + types.add(element.type); + } + + if (custom == false && + (_inAppClickHandler != null || _inAppDismissedHandler != null)) { + types.add('CustomInAppCallback'); + } + + if (types.isNotEmpty) { + await channel.invokeMethod('registerInAppCallbacks', types); + } } /// Method for handling push-notification click. @@ -211,6 +226,7 @@ class MindboxMethodHandler { required String operationSystemName, required Map operationBody, }) async { + await _initFuture; if (_initialized) { channel.invokeMethod('executeAsyncOperation', [ operationSystemName, @@ -231,6 +247,7 @@ class MindboxMethodHandler { required Function(String success) onSuccess, required Function(MindboxError) onError, }) async { + await _initFuture; if (_initialized) { channel.invokeMethod('executeSyncOperation', [ operationSystemName, @@ -313,6 +330,7 @@ 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] @@ -324,9 +342,9 @@ class MindboxMethodHandler { void _setMethodCallHandler() { channel.setMethodCallHandler((call) { - switch (call.method) { - case 'pushClicked': - _logInfo('Handle method pushClicked'); + switch (call.method) { + case 'pushClicked': + _logInfo('Handle method pushClicked'); if (_pushClickHandler != null) { if (call.arguments is List) { _logInfo('Return data from push with parameters link = ' @@ -339,18 +357,18 @@ class MindboxMethodHandler { link: call.arguments[0], payload: 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; - } + 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; + } return Future.value(true); }); _methodHandlerSet = true; diff --git a/mindbox_platform_interface/pubspec.yaml b/mindbox_platform_interface/pubspec.yaml index c96ceab..20ec0c8 100644 --- a/mindbox_platform_interface/pubspec.yaml +++ b/mindbox_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: mindbox_platform_interface description: Mindbox platform interface. -version: 2.13.2-rc +version: 2.13.4 homepage: https://mindbox.cloud/ repository: https://github.com/mindbox-cloud/flutter-sdk/tree/master/mindbox_platform_interface