Repro Flutter Plugin

  • Repro plugin for Flutter.
  • Support all the features of Repro except for WebView event tracking.

How to run the example app

Replace the following YOUR SDK TOKEN by your SDK token (if you don't have a Repro account, sign-up here for free).

android/app/src/main/java/io/repro/repro_flutter_example/MyApplication.java:

public class MyApplication extends FlutterApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        Repro.setup(this, "YOUR SDK TOKEN");

ios/Runner/AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [GeneratedPluginRegistrant registerWithRegistry:self];
    // Override point for customization after application launch.
    [Repro setup:@"YOUR SDK TOKEN"];

Go to example directory and run:

flutter run

Enable Push Notifications in the example app

1. Add Firebase Flutter Plugin

Please refer to the official document of Firebase to:

  • Add Firebase Flutter Plugin
  • Add google-services.json and GoogleServices-Info.plist

NOTE (for iOS): Because you may not be able to create the same bundle id for testing, remember to change the bundle id io.repro.reproFlutterExample to one you have control of.

2. Setup APNs Certificate and FCM

Please refer to the following document of Repro:

Uncomment the following code which implements Push Notifications:

android/app/src/main/AndroidManifest.xml:

        <!-- To enable push notifications on Repro, uncomment the following: -->
        <receiver
            android:name="io.repro.android.ReproReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="io.repro.repro_flutter_example" />
            </intent-filter>
        </receiver>

        <meta-data
            android:name="io.repro.android.PushNotification.ChannelId"
            android:value="io.repro.flutter.repro_test.channel_id">
        </meta-data>

        <meta-data
            android:name="io.repro.android.PushNotification.ChannelName"
            android:resource="@string/repro_channel_name">
        </meta-data>

        <meta-data
            android:name="io.repro.android.PushNotification.ChannelDescription"
            android:resource="@string/repro_channel_description">
        </meta-data>

        <meta-data
            android:name="io.repro.android.PushNotification.ShowBadge"
            android:value="true">
        </meta-data>

android/app/src/main/res/values/strings.xml:

    <!-- To enable push notifications on Repro, uncomment the following: -->
    <string name="repro_channel_name">Channel Name</string>
    <string name="repro_channel_description">Channel Description</string>

android/app/src/main/java/io/repro/repro_flutter_example/MyApplication.java:

    public void onCreate() {
        super.onCreate();
        Repro.setup(this, "YOUR SDK TOKEN");

        // To enable push notifications on Repro, uncomment the following:
        Repro.enablePushNotification();

ios/Runner/AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...

    // To enable push notifications on Repro, uncomment the following:
    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
        [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) {
        }];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    } else {
        UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }

    ...
}

// To enable push notifications on Repro, uncomment the following:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    [Repro setPushDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    NSLog(@"Remote Notification Error: %@", error);
}

4. Send Push Notifications from Repro

Please see the Dashboard Guide of Repro.

How to add Repro Flutter Plugin to an app

Add Repro Flutter Plugin

1. Add dependencies

Add repro_flutter to your pubspec.yaml and run flutter packages get:

dependencies:
  flutter:
    sdk: flutter
  ...
  repro_flutter: ^0.0.1 # add this line

2. Add native code (Android)

Add dependencies to android/app/build.gradle:

dependencies {
    implementation 'io.repro:repro-android-sdk:4.0.4' // add this line
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Add a custom Application class extending from io.flutter.app.FlutterApplication. If you've done this before for the other reasons, please skip this step and just add the call to Repro.setup (in below).

Create a new Application class under android/app/src/main/your/package/name:

package your.package.name;

import io.flutter.app.FlutterApplication;
import io.repro.android.Repro;

public class MyApplication extends FlutterApplication {

    @Override
    public void onCreate() {
        super.onCreate();
    }
}

Set it to android/app/src/main/AndroidManifest.xml:

      <application
-         android:name="io.flutter.app.FlutterApplication"
+         android:name="your.package.name.MyApplication"
          android:label="repro_integration_test"
          android:icon="@mipmap/ic_launcher">

Call Repro.setup in your Application class (replace YOUR SDK TOKEN by your SDK token):

    public void onCreate() {
        super.onCreate();
        Repro.setup(this, "YOUR SDK TOKEN"); // add this line
    }

3. Add native code (iOS)

Call Repro#setup in ios/Runner/AppDelegate.m (replace YOUR SDK TOKEN by your SDK token):

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Override point for customization after application launch.
  [Repro setup:@"YOUR SDK TOKEN"]; // add this line
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

Enable Push Notifications

1. Add Firebase Flutter Plugin

Please refer to the official document of Firebase to:

  • Add Firebase Flutter Plugin
  • Add google-services.json and GoogleServices-Info.plist

2. Setup for Android

Please refer to the following document of Repro:

3. Setup for iOS

Please refer to the following document of Repro:

Development Guide

Please see the example code in example/lib/main.dart while refer to the Development Guide of Repro.

Libraries

repro