Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 990bba9

Browse files
prakhar1989collinjackson
authored andcommitted
[firebase_in_app_messaging] add new plugin (#1791)
* add plugin for firebase inappmessaging
1 parent 89b1453 commit 990bba9

File tree

77 files changed

+2076
-0
lines changed

Some content is hidden

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

77 files changed

+2076
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
7+
build/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 2e540931f73593e35627592ca4f9a4ca3035ed31
8+
channel: stable
9+
10+
project_type: plugin
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* Initial release.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2018, the Chromium project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# firebase_in_app_messaging plugin
2+
3+
A Flutter plugin to use the [Firebase In-App Messaging API](https://firebase.google.com/products/in-app-messaging).
4+
5+
For Flutter plugins for other Firebase products, see [FlutterFire.md](https://github.com/flutter/plugins/blob/master/FlutterFire.md).
6+
7+
*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome!
8+
9+
## Usage
10+
11+
### Import the firebase_in_app_messaging plugin
12+
To use the firebase_in_app_messaging plugin, follow the [plugin installation instructions](https://pub.dartlang.org/packages/firebase_in_app_messaging#pub-pkg-tab-installing).
13+
14+
### Android integration
15+
16+
There are a few extra steps required for the Android integration. Enable the Google services by configuring the Gradle scripts as such.
17+
18+
1. Add the classpath to the `[project]/android/build.gradle` file.
19+
```gradle
20+
dependencies {
21+
// Example existing classpath
22+
classpath 'com.android.tools.build:gradle:3.3.0'
23+
// Add the google services classpath
24+
classpath 'com.google.gms:google-services:4.2.0'
25+
}
26+
```
27+
28+
2. Add the apply plugin to the `[project]/android/app/build.gradle` file.
29+
```gradle
30+
// ADD THIS AT THE BOTTOM
31+
apply plugin: 'com.google.gms.google-services'
32+
```
33+
34+
*Note:* If this section is not completed you will get an error like this:
35+
```
36+
java.lang.IllegalStateException:
37+
Default FirebaseApp is not initialized in this process [package name].
38+
Make sure to call FirebaseApp.initializeApp(Context) first.
39+
```
40+
41+
*Note:* When you are debugging on Android, use a device or AVD with Google Play services.
42+
Otherwise you will not be able to use Firebase In-App Messaging.
43+
44+
### Use the plugin
45+
46+
To show In-App Messages in your app, no extra setup is required - just import the plugin and you
47+
are good to go. However, to modify message behavior (as documented [here](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior)), the plugin provides the following methods -
48+
49+
First off, add the following imports to your Dart code:
50+
```dart
51+
import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart';
52+
```
53+
54+
#### Programmatic Triggers ([docs](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#trigger_in-app_messages_programmatically))
55+
56+
To trigger in-app messages programmatically
57+
58+
```dart
59+
FirebaseInAppMessaging.triggerEvent('eventName');
60+
```
61+
62+
#### Temporarily disable in-app messages ([docs](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#temporarily_disable_in-app_messages))
63+
64+
If you'd like to suppress message displays for any reason, for example to avoid interrupting a sequence of payment processing screens, you can do that the following
65+
66+
```dart
67+
FirebaseInAppMessaging.setMessagesSuppressed(true);
68+
69+
70+
// To re-enable
71+
FirebaseInAppMessaging.setMessagesSuppressed(false);
72+
```
73+
74+
#### Enable opt-out message delivery ([docs](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#enable_opt-out_message_delivery))
75+
76+
First, follow the step outlined [here](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior#enable_opt-out_message_delivery) for both iOS and Android. Then add the following code in your app:
77+
78+
```dart
79+
FirebaseInAppMessaging.setAutomaticDataCollectionEnabled(false);
80+
```
81+
82+
## Example
83+
84+
See the [example application](https://github.com/flutter/plugins/tree/master/packages/firebase_in_app_messaging/example) source
85+
for a complete sample app using the Firebase In-App Messaging.
86+
87+
## Issues and feedback
88+
89+
Please file [issues](https://github.com/flutter/flutter/issues/new)
90+
to send feedback or report a bug. Thank you!
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
group 'com.example.firebase_in_app_messaging'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
repositories {
6+
google()
7+
jcenter()
8+
}
9+
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:3.3.0'
12+
}
13+
}
14+
15+
rootProject.allprojects {
16+
repositories {
17+
google()
18+
jcenter()
19+
}
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
24+
android {
25+
compileSdkVersion 28
26+
27+
defaultConfig {
28+
minSdkVersion 16
29+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
30+
}
31+
lintOptions {
32+
disable 'InvalidPackage'
33+
}
34+
dependencies {
35+
api 'com.google.firebase:firebase-inappmessaging-display:18.0.1'
36+
implementation 'androidx.annotation:annotation:1.0.0'
37+
}
38+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.jvmargs=-Xmx1536M
2+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'firebase_in_app_messaging'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.firebase_in_app_messaging">
3+
</manifest>

0 commit comments

Comments
 (0)