forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request flutter#21 from collinjackson/migrate_fiam
[firebase_in_app_messaging] migrate to new repository
- Loading branch information
Showing
77 changed files
with
2,111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.packages | ||
.pub/ | ||
|
||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# 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: 2e540931f73593e35627592ca4f9a4ca3035ed31 | ||
channel: stable | ||
|
||
project_type: plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## 0.0.1+3 | ||
|
||
* Update AGP, gradle and inappmessaging-display versions on Android. | ||
|
||
## 0.0.1+2 | ||
|
||
* Remove dependency `androidx.annotation:annotation:1.0.0`. | ||
|
||
## 0.0.1+1 | ||
|
||
* Update google-services Android gradle plugin to 4.3.0 in documentation and examples. | ||
|
||
## 0.0.1 | ||
|
||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright 2018, the Chromium project authors. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# firebase_in_app_messaging plugin | ||
|
||
A Flutter plugin to use the [Firebase In-App Messaging API](https://firebase.google.com/products/in-app-messaging). | ||
|
||
*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback](https://github.com/FirebaseExtended/flutterfire/issues) and [Pull Requests](https://github.com/FirebaseExtended/flutterfire/pulls) are most welcome! | ||
|
||
## Usage | ||
|
||
### Import the firebase_in_app_messaging plugin | ||
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). | ||
|
||
### Android integration | ||
|
||
There are a few extra steps required for the Android integration. Enable the Google services by configuring the Gradle scripts as such. | ||
|
||
1. Add the classpath to the `[project]/android/build.gradle` file. | ||
```gradle | ||
dependencies { | ||
// Example existing classpath | ||
classpath 'com.android.tools.build:gradle:3.3.0' | ||
// Add the google services classpath | ||
classpath 'com.google.gms:google-services:4.3.0' | ||
} | ||
``` | ||
|
||
2. Add the apply plugin to the `[project]/android/app/build.gradle` file. | ||
```gradle | ||
// ADD THIS AT THE BOTTOM | ||
apply plugin: 'com.google.gms.google-services' | ||
``` | ||
|
||
*Note:* If this section is not completed you will get an error like this: | ||
``` | ||
java.lang.IllegalStateException: | ||
Default FirebaseApp is not initialized in this process [package name]. | ||
Make sure to call FirebaseApp.initializeApp(Context) first. | ||
``` | ||
|
||
*Note:* When you are debugging on Android, use a device or AVD with Google Play services. | ||
Otherwise you will not be able to use Firebase In-App Messaging. | ||
|
||
### Use the plugin | ||
|
||
To show In-App Messages in your app, no extra setup is required - just import the plugin and you | ||
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 - | ||
|
||
First off, add the following imports to your Dart code: | ||
```dart | ||
import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart'; | ||
``` | ||
|
||
#### Programmatic Triggers ([docs](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#trigger_in-app_messages_programmatically)) | ||
|
||
To trigger in-app messages programmatically | ||
|
||
```dart | ||
FirebaseInAppMessaging.triggerEvent('eventName'); | ||
``` | ||
|
||
#### Temporarily disable in-app messages ([docs](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#temporarily_disable_in-app_messages)) | ||
|
||
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 | ||
|
||
```dart | ||
FirebaseInAppMessaging.setMessagesSuppressed(true); | ||
// To re-enable | ||
FirebaseInAppMessaging.setMessagesSuppressed(false); | ||
``` | ||
|
||
#### Enable opt-out message delivery ([docs](https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=android#enable_opt-out_message_delivery)) | ||
|
||
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: | ||
|
||
```dart | ||
FirebaseInAppMessaging.setAutomaticDataCollectionEnabled(false); | ||
``` | ||
|
||
## Example | ||
|
||
See the [example application](https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_in_app_messaging/example) source | ||
for a complete sample app using the Firebase In-App Messaging. | ||
|
||
## Issues and feedback | ||
|
||
Please file [issues](https://github.com/flutter/flutter/issues/new) | ||
to send feedback or report a bug. Thank you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
group 'com.example.firebase_in_app_messaging' | ||
version '1.0-SNAPSHOT' | ||
|
||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.4.2' | ||
} | ||
} | ||
|
||
rootProject.allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
dependencies { | ||
api 'com.google.firebase:firebase-inappmessaging-display:18.0.2' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'firebase_in_app_messaging' |
3 changes: 3 additions & 0 deletions
3
packages/firebase_in_app_messaging/android/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.firebase_in_app_messaging"> | ||
</manifest> |
59 changes: 59 additions & 0 deletions
59
...oid/src/main/java/com/example/firebase_in_app_messaging/FirebaseInAppMessagingPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package com.example.firebase_in_app_messaging; | ||
|
||
import com.google.firebase.inappmessaging.FirebaseInAppMessaging; | ||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.MethodChannel; | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
import io.flutter.plugin.common.MethodChannel.Result; | ||
import io.flutter.plugin.common.PluginRegistry.Registrar; | ||
|
||
/** FirebaseInAppMessagingPlugin */ | ||
public class FirebaseInAppMessagingPlugin implements MethodCallHandler { | ||
private final FirebaseInAppMessaging instance; | ||
|
||
public static void registerWith(Registrar registrar) { | ||
final MethodChannel channel = | ||
new MethodChannel(registrar.messenger(), "plugins.flutter.io/firebase_in_app_messaging"); | ||
channel.setMethodCallHandler(new FirebaseInAppMessagingPlugin()); | ||
} | ||
|
||
private FirebaseInAppMessagingPlugin() { | ||
instance = FirebaseInAppMessaging.getInstance(); | ||
} | ||
|
||
@Override | ||
public void onMethodCall(MethodCall call, Result result) { | ||
switch (call.method) { | ||
case "triggerEvent": | ||
{ | ||
String eventName = call.argument("eventName"); | ||
instance.triggerEvent(eventName); | ||
result.success(null); | ||
break; | ||
} | ||
case "setMessagesSuppressed": | ||
{ | ||
Boolean suppress = (Boolean) call.arguments; | ||
instance.setMessagesSuppressed(suppress); | ||
result.success(null); | ||
break; | ||
} | ||
case "setAutomaticDataCollectionEnabled": | ||
{ | ||
Boolean enabled = (Boolean) call.arguments; | ||
instance.setAutomaticDataCollectionEnabled(enabled); | ||
result.success(null); | ||
break; | ||
} | ||
default: | ||
{ | ||
result.notImplemented(); | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
.dart_tool/ | ||
.flutter-plugins | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Android related | ||
**/android/**/gradle-wrapper.jar | ||
**/android/.gradle | ||
**/android/captures/ | ||
**/android/gradlew | ||
**/android/gradlew.bat | ||
**/android/local.properties | ||
**/android/**/GeneratedPluginRegistrant.java | ||
|
||
# iOS/XCode related | ||
**/ios/**/*.mode1v3 | ||
**/ios/**/*.mode2v3 | ||
**/ios/**/*.moved-aside | ||
**/ios/**/*.pbxuser | ||
**/ios/**/*.perspectivev3 | ||
**/ios/**/*sync/ | ||
**/ios/**/.sconsign.dblite | ||
**/ios/**/.tags* | ||
**/ios/**/.vagrant/ | ||
**/ios/**/DerivedData/ | ||
**/ios/**/Icon? | ||
**/ios/**/Pods/ | ||
**/ios/**/.symlinks/ | ||
**/ios/**/profile | ||
**/ios/**/xcuserdata | ||
**/ios/.generated/ | ||
**/ios/Flutter/App.framework | ||
**/ios/Flutter/Flutter.framework | ||
**/ios/Flutter/Generated.xcconfig | ||
**/ios/Flutter/app.flx | ||
**/ios/Flutter/app.zip | ||
**/ios/Flutter/flutter_assets/ | ||
**/ios/ServiceDefinitions.json | ||
**/ios/Runner/GeneratedPluginRegistrant.* | ||
|
||
# Exceptions to above rules. | ||
!**/ios/**/default.mode1v3 | ||
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# 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: 2e540931f73593e35627592ca4f9a4ca3035ed31 | ||
channel: stable | ||
|
||
project_type: app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# firebase_in_app_messaging_example | ||
|
||
Demonstrates how to use the firebase_in_app_messaging plugin. | ||
|
Oops, something went wrong.