Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example/flutter_example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,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
23 changes: 17 additions & 6 deletions example/flutter_example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ 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()
Expand Down Expand Up @@ -41,27 +43,36 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "cloud.mindbox.flutter_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
buildToolsVersion '34.0.0'
}

flutter {
source '../..'
}

dependencies {}
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'
}
28 changes: 20 additions & 8 deletions example/flutter_example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:label="flutter_example"
android:name="${applicationName}"
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher">

<service android:name=".MindboxFirebaseMessagingService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>

<meta-data
android:name="com.huawei.hms.client.channel.androidMarket"
android:value="false" />
<service android:name=".MindboxHuaweiMessagingService" android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT"/>
</intent-filter>
</service>

<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -29,16 +46,11 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
</application>
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
<action android:name="com.huawei.hms.core.aidlservice" />
</intent>
</queries>
</manifest>
Original file line number Diff line number Diff line change
@@ -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))
}
}
Original file line number Diff line number Diff line change
@@ -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
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь бы добавить хотя бы комментарий, в каком случае мы здесь окажемся. Аналогично и для Huawei

}

}
Original file line number Diff line number Diff line change
@@ -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
}

}
}
21 changes: 18 additions & 3 deletions example/flutter_example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
buildscript {
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'}
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.0'
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}
}

allprojects {
repositories {
google()
mavenCentral()
maven {url 'https://developer.huawei.com/repo/'}
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
}
3 changes: 2 additions & 1 deletion example/flutter_example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ pluginManagement {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://developer.huawei.com/repo/' }
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "com.android.application" version '7.4.2' apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

Expand Down
30 changes: 0 additions & 30 deletions example/flutter_example/test/widget_test.dart

This file was deleted.