Skip to content

Commit 2d1bb5f

Browse files
authored
Merge pull request #142 from mindbox-cloud/release/2.13.0
Bump SDK version to 2.13.0
2 parents 4306601 + 58324cf commit 2d1bb5f

File tree

59 files changed

+676
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+676
-390
lines changed

.github/workflows/analyze_and_test.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ jobs:
6565
- run: cd mindbox_ios && flutter pub get
6666
- run: cd mindbox_ios && flutter analyze
6767
- run: cd mindbox_ios && flutter test
68-
68+
69+
example_flutter_test:
70+
name: example running analyze
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: actions/setup-java@v1
75+
with:
76+
java-version: "12.x"
77+
- uses: subosito/flutter-action@v2
78+
with:
79+
channel: "stable"
80+
81+
- name: lint example
82+
run: cd example/flutter_example && flutter pub get && flutter analyze
83+
6984
plugin_flutter_test:
7085
name: plugin running analyze and tests
7186
runs-on: ubuntu-latest
@@ -77,7 +92,10 @@ jobs:
7792
- uses: subosito/flutter-action@v2
7893
with:
7994
channel: "stable"
80-
95+
96+
- name: lint example
97+
run: cd example/flutter_example && flutter pub get && flutter analyze
98+
8199
- name: Add publish_to tag in mindbox_android
82100
run: |
83101
cd mindbox_android && echo "publish_to: 'none'" | cat - pubspec.yaml > temp && mv temp pubspec.yaml

.github/workflows/gitleaks-secrets-validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fetch-depth: 0
1414

1515
- name: Run Gitleaks
16-
uses: gitleaks/gitleaks-action@v2.3.4
16+
uses: gitleaks/gitleaks-action@v2
1717
env:
1818
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1919
GITLEAKS_LICENSE: ${{ secrets.MINDBOX_GITLEAKS_LICENSE }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Validate PR description is not empty
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
issue_comment:
7+
types: [created]
8+
9+
jobs:
10+
check-description:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out the repository
15+
uses: actions/checkout@v4
16+
17+
- name: Check PR description
18+
id: validate_description_step
19+
uses: actions/github-script@v7
20+
with:
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
script: |
23+
const pr = context.payload.pull_request;
24+
if (!pr || !pr.body || pr.body.trim().length === 0) {
25+
core.setOutput('pr_description_check_passed', 'false');
26+
}
27+
else {
28+
core.setOutput('pr_description_check_passed', 'true');
29+
}
30+
- name: Find Comment
31+
uses: peter-evans/find-comment@v3
32+
id: fc
33+
with:
34+
issue-number: ${{ github.event.pull_request.number }}
35+
comment-author: 'github-actions[bot]'
36+
37+
- name: Update comment with validation failed statement
38+
if: ${{ steps.validate_description_step.outputs.pr_description_check_passed == 'false' }}
39+
uses: peter-evans/create-or-update-comment@v4
40+
with:
41+
issue-number: ${{ github.event.pull_request.number }}
42+
comment-id: ${{ steps.fc.outputs.comment-id }}
43+
edit-mode: replace
44+
body: |
45+
⚠️ **Пожалуйста, добавь описание к pull request.**
46+
Описание pull request помогает лучше понять изменения, которые вы вносите, облегчает процесс ревью и поиска причин инцидентов.
47+
Описание должно содержать **причину** изменений: какую **проблему** решаем, **зачем** делаем изменение, а не что изменилось.
48+
Причина может быть в описании issue или в треде, тогда достаточно указать ссылку.
49+
* Добавь ссылку на issue или тред, в котором раскрыта причина изменения
50+
* Если требуется, коротко опиши зачем делаешь изменение, какую проблему решаешь
51+
Спасибо!
52+
53+
- name: Fail the job if description is empty
54+
if: ${{ steps.validate_description_step.outputs.pr_description_check_passed == 'false' }}
55+
run: |
56+
echo "⚠️ Ошибка: Пожалуйста, добавьте описание к pull request."
57+
exit 1

.github/workflows/trigger-build-app.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,10 @@ jobs:
2020
commits=$(git log -3 --pretty=format:"%s")
2121
echo "commits=$commits" >> $GITHUB_ENV
2222
23-
- name: Get Flutter Mindbox SDK Version
24-
run: |
25-
sdkVersion=$(grep 'version:' mindbox/pubspec.yaml | awk '{print $2}')
26-
echo "sdkVersion=$sdkVersion" >> $GITHUB_ENV
27-
2823
- name: Trigger build workflow in flutter-app repo
29-
uses: benc-uk/workflow-dispatch@v1
30-
with:
31-
token: ${{ secrets.PAT_FLUTTER_APP }}
32-
workflow: buildApplicationAfterTrigger.yml
33-
repo: mindbox-cloud/flutter-app
34-
ref: develop
35-
inputs: '{"branch": "{{ github.head_ref }}", "commits": "${{ env.commits }}", "sdkVersion": "${{ env.sdkVersion }}"}'
24+
run: |
25+
curl --location 'https://mindbox.gitlab.yandexcloud.net/api/v4/projects/1089/trigger/pipeline' \
26+
--form 'token="${{ secrets.GITLAB_TRIGGER_TOKEN }}"' \
27+
--form 'ref="develop"' \
28+
--form "variables[INPUT_BRANCH]=\"${{ github.head_ref }}\"" \
29+
--form "variables[INPUT_COMMITS]=\"${{ env.commits }}\""
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
101
include: package:flutter_lints/flutter.yaml
112

123
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
234
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
5+
file_names: false
6+
avoid_print: false
7+
lines_longer_than_80_chars: false
8+
cancel_subscriptions: true
9+
constant_identifier_names: true
10+
directives_ordering: false
11+
empty_constructor_bodies: true
12+
flutter_style_todos: true
13+
implementation_imports: true
14+
package_names: true
15+
package_prefixed_library_names: true
16+
prefer_final_locals: true
17+
sort_child_properties_last: true
18+
sort_constructors_first: true
19+
sort_unnamed_constructors_first: true
20+
type_annotate_public_apis: false
21+
unnecessary_await_in_return: true
22+
prefer_is_not_empty: true
23+
avoid_empty_else: true
24+
avoid_returning_null_for_void: true
25+
no_duplicate_case_values: true
26+
prefer_typing_uninitialized_variables: true
27+
public_member_api_docs: false
28+
always_put_control_body_on_new_line: true
29+
curly_braces_in_flow_control_structures: true
2630

27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options
31+
# See lint rules here https://dart.dev/tools/linter-rules#lints

example/flutter_example/android/app/build.gradle

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (flutterVersionName == null) {
2727
android {
2828
namespace "cloud.mindbox.flutter_example"
2929
compileSdk flutter.compileSdkVersion
30-
ndkVersion flutter.ndkVersion
30+
ndkVersion "26.1.10909125"
3131

3232
compileOptions {
3333
sourceCompatibility JavaVersion.VERSION_1_8
@@ -51,6 +51,15 @@ android {
5151
multiDexEnabled true
5252
}
5353

54+
signingConfigs {
55+
debug {
56+
storePassword "android"
57+
keyAlias "androiddebugkey"
58+
storeFile file("debug.keystore")
59+
keyPassword "android"
60+
}
61+
}
62+
5463
buildTypes {
5564
release {
5665
signingConfig signingConfigs.debug
@@ -63,7 +72,7 @@ flutter {
6372
source '../..'
6473
}
6574

66-
ext.mindbox_version = "2.10.0"
75+
ext.mindbox_version = "2.13.0"
6776

6877
dependencies {
6978
implementation 'androidx.multidex:multidex:2.0.1'
@@ -73,10 +82,13 @@ dependencies {
7382
implementation platform('com.google.firebase:firebase-bom:32.8.1')
7483
implementation 'com.google.firebase:firebase-messaging:23.4.1'
7584
//https://developers.mindbox.ru/docs/huawei-send-push-notifications-flutter
76-
implementation "cloud.mindbox:mindbox-huawei"
85+
implementation 'cloud.mindbox:mindbox-huawei'
7786
implementation 'com.huawei.hms:push:6.11.0.300'
7887
implementation 'com.google.code.gson:gson:2.8.8'
7988

89+
implementation 'cloud.mindbox:mindbox-rustore'
90+
implementation 'ru.rustore.sdk:pushclient:6.5.1'
91+
8092
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1"
8193
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"
8294
}

example/flutter_example/android/app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
23
package="cloud.mindbox.flutter_example">
34

45
<application
@@ -18,6 +19,12 @@
1819
</intent-filter>
1920
</service>
2021

22+
<service android:name=".MindboxRuStoreMessagingService" android:exported="true" tools:ignore="ExportedService">
23+
<intent-filter>
24+
<action android:name="ru.rustore.sdk.pushclient.MESSAGING_EVENT" />
25+
</intent-filter>
26+
</service>
27+
2128
<activity
2229
android:name=".MainActivity"
2330
android:exported="true"
@@ -45,6 +52,10 @@
4552
android:name="flutterEmbedding"
4653
android:value="2" />
4754

55+
<meta-data
56+
android:name="ru.rustore.sdk.pushclient.project_id"
57+
android:value="MPYu6sSEZy8Vl-wYVkqFwwuaFNVlsBvx" />
58+
4859
</application>
4960
<queries>
5061
<intent>

example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MainApplication.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.util.Log
66
import cloud.mindbox.mobile_sdk.Mindbox
77
import cloud.mindbox.mindbox_firebase.MindboxFirebase
88
import cloud.mindbox.mindbox_huawei.MindboxHuawei
9+
import cloud.mindbox.mindbox_rustore.MindboxRuStore
910
import cloud.mindbox.mobile_sdk.pushes.MindboxRemoteMessage
1011
import io.flutter.embedding.engine.FlutterEngine
1112
import io.flutter.plugin.common.EventChannel
@@ -20,7 +21,7 @@ class MainApplication : Application() {
2021
private val gson = Gson()
2122
override fun onCreate() {
2223
super.onCreate()
23-
Mindbox.initPushServices(applicationContext, listOf(MindboxFirebase, MindboxHuawei))
24+
Mindbox.initPushServices(applicationContext, listOf(MindboxFirebase, MindboxHuawei, MindboxRuStore))
2425
}
2526

2627
fun setupEventChannel(flutterEngine: FlutterEngine) {

example/flutter_example/android/app/src/main/kotlin/cloud/mindbox/flutter_example/MindboxHuaweiMessagingService.kt

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ package cloud.mindbox.flutter_example
33
import cloud.mindbox.mobile_sdk.Mindbox
44
import com.huawei.hms.push.*
55
import cloud.mindbox.mindbox_huawei.MindboxHuawei
6+
import kotlinx.coroutines.*
67

78
class MindboxHuaweiMessagingService: HmsMessageService() {
9+
10+
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
11+
812
override fun onNewToken(token: String) {
913
super.onNewToken(token)
1014
Mindbox.updatePushToken(applicationContext, token, MindboxHuawei)
@@ -17,31 +21,40 @@ class MindboxHuaweiMessagingService: HmsMessageService() {
1721
val channelDescription = "default_channel_description"
1822
val pushSmallIcon = android.R.drawable.ic_dialog_info
1923

20-
val messageWasHandled = Mindbox.handleRemoteMessage(
21-
context = applicationContext,
22-
message = remoteMessage,
23-
activities = mapOf(),
24-
channelId = channelId,
25-
channelName = channelName,
26-
pushSmallIcon = pushSmallIcon,
27-
defaultActivity = MainActivity::class.java,
28-
channelDescription = channelDescription
29-
)
30-
31-
// Method for checking if push is from Mindbox
32-
val isMindboxPush = MindboxHuawei.isMindboxPush(remoteMessage = remoteMessage)
33-
34-
// Method for getting info from Mindbox push
35-
val mindboxMessage = MindboxHuawei.convertToMindboxRemoteMessage(remoteMessage = remoteMessage)
36-
// If you want to save the notification you can call your save function from here.
37-
mindboxMessage?.let {
38-
val app = applicationContext as MainApplication
39-
app.saveNotification(it)
40-
}
41-
42-
if (!messageWasHandled) {
43-
//If the push notification was not from Mindbox or it contains incorrect data, then you can write a fallback to process it
24+
// On some devices, onMessageReceived may be executed on the main thread
25+
// We recommend handling push messages asynchronously
26+
coroutineScope.launch {
27+
val messageWasHandled = Mindbox.handleRemoteMessage(
28+
context = applicationContext,
29+
message = remoteMessage,
30+
activities = mapOf(),
31+
channelId = channelId,
32+
channelName = channelName,
33+
pushSmallIcon = pushSmallIcon,
34+
defaultActivity = MainActivity::class.java,
35+
channelDescription = channelDescription
36+
)
37+
38+
// Method for checking if push is from Mindbox
39+
val isMindboxPush = MindboxHuawei.isMindboxPush(remoteMessage = remoteMessage)
40+
41+
// Method for getting info from Mindbox push
42+
val mindboxMessage =
43+
MindboxHuawei.convertToMindboxRemoteMessage(remoteMessage = remoteMessage)
44+
// If you want to save the notification you can call your save function from here.
45+
mindboxMessage?.let {
46+
val app = applicationContext as MainApplication
47+
app.saveNotification(it)
48+
}
49+
50+
if (!messageWasHandled) {
51+
//If the push notification was not from Mindbox or it contains incorrect data, then you can write a fallback to process it
52+
}
4453
}
54+
}
4555

56+
override fun onDestroy() {
57+
super.onDestroy()
58+
coroutineScope.cancel()
4659
}
4760
}

0 commit comments

Comments
 (0)