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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
45 changes: 45 additions & 0 deletions example/flutter_example/.metadata
Original file line number Diff line number Diff line change
@@ -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'
71 changes: 71 additions & 0 deletions example/flutter_example/README.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
78 changes: 78 additions & 0 deletions example/flutter_example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="mindbox_android_example"

<application
android:label="flutter_example"
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:exported="true"
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
Expand All @@ -18,15 +36,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -37,5 +46,11 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />

</application>
<queries>
<intent>
<action android:name="com.huawei.hms.core.aidlservice" />
</intent>
</queries>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cloud.mindbox.flutter_example

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()
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
}
}

}
Loading