webinstats_flutter_plugin 0.0.5 copy "webinstats_flutter_plugin: ^0.0.5" to clipboard
webinstats_flutter_plugin: ^0.0.5 copied to clipboard

WebInStats In-App Marketing SDK Flutter plugin.

webinstats #

A Flutter plugin to integrate webinstats SDK in your Flutter app.

Getting Started #

  1. Add the latest version of the package in your pubspec.yaml
  2. For iOS go to the ios folder and run pod install
  3. import 'package:webinstats_flutter/webinstats_flutter.dart';
  4. For Android You should add below to ~/android/app/src/main/AndroidManifest.xml
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

Available Methods #

  1. execute
  2. addItem
  3. createEvent
  4. setPushClickCallback

For Push notification #

Adding the Push Notification Product to the applications:

You must follow the steps on this page for the WebInStats-PushStats product to work in your applications.

Android: #

Initialize a Firebase project and add your Firebase application’s configuration file (google-service.json) below the app section :

  • Add firebase_core to the pubspec.yaml and initialize the firebase as given below :
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}

  • Add webinstats dependency to the app/build.gradle inside android :
dependencies {
       `implementation 'com.github.WebInStats:android_wis:3.0.55@aar'`
   }


- Add the line below to the AndroidManifest.xml file between application tags :

       <!-- Add your notification icon's source file to AndroidManifest.xml -->
        <!-- before 5.0 API 21 @drawable/file_name -->
           <meta-data
            android:name="push_notification_icon_old"
            android:resource="__icon_source_file"/>
        <!-- 5.0 API 21+ @drawable/file_name -->
           <meta-data
            android:name="push_notification_icon"
            android:resource="@__icon_source_file"/ >
        <!-- 8.0 API 26+ -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="default_notification_channel_id"/>

      <service
      android:name="webinstats.android_wis.WebinstatsMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
      <service
      android:name="webinstats.android_wis.WisHMSMessagingService"
      android:exported="false">
            <intent-filter>
                <action android:name="com.huawei.push.action.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

  • Add the maven { url 'https://jitpack.io' } in the android/build.gradle
allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}
  • Add _enable_push:1 to your execute method to enable the push notification:
ElevatedButton(
             child: const Text('Execute'),
             onPressed: () => Webinstats.execute(
               companyId,
               domain,
               {
                 "companyId": "__COMPANY_ID__",
                 "domain": '//__YOUR_DOMAIN__.webinstats.com',
                 'p': "Other",
                 'wistest': "full",
                 '_enable_push': '1',
                 'cuid': '0'
               },
             ),
           ),

Now you are ready to get the push notification from the portal:

  • If you want to track the notification click of your android app. Add the below codes to you MainActivity. java class in you android project
 @Override
  public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Bundle bundle = intent.getExtras();
    final Uri appLinkData = intent.getData();
    new Webinstats("//__YOUR_DOMAIN__.webinstats.com","__COMPANY_ID__","0").trackDeepLink(this,appLinkData,bundle);
  }

```java
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getIntent().getExtras();
        Uri appLinkData = getIntent().getData();
        new Webinstats("//__YOUR_DOMAIN__.webinstats.com", "__COMPANY_ID__", "0").trackDeepLink(this, appLinkData, bundle);
    }

IOS: #

Enable Push Notifications in Capabilities tab in the xcode:

  • Initialize a Firebase project and add your Firebase application’s configuration file (GoogleService-info. plist):

  • To access methods from SDK in your AppDelegate.m file and for listen the firebase push notification add the following line to the beginning of the (Appdelegate.m) class.

  @import iOS_wis;
  @import FirebaseMessaging;
  • At the end of your didFinishLaunchingWithOptions method, add the following line:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [[[Webinstats alloc] init:@"//__YOUR_SUBDOMAIN__.webinstats.com/" :@"___YOUR_COMPANY_ID___" :@"0"] register:application didFinishLaunchingWithOptions:launchOptions];
        return YES;
}

  • Add the following methods, in your AppDelegate.m:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    [[[Webinstats alloc] init:@"//__YOUR_SUBDOMAIN__.webinstats.com/" :@"___YOUR_COMPANY_ID___" :@"0"] didReceiveNotification:application didReceiveRemoteNotification:userInfo];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
   [Webinstats registerWithDeviceTokenWithDeviceToken:deviceToken];
}

Now you are ready to get the push notification from the portal:

  • You can add the callback fon click on notification in ios by adding add the below function:

ElevatedButton(
             child: const Text('Set Push Click Callback'),
             onPressed: () => Webinstats.setPushClickCallback(
               (data) {
                 print('setPushClickCallback: data from the app: $data');
               },
               'COMPANY_ID',
             ),
           ),

0
likes
120
pub points
16%
popularity

Publisher

unverified uploader

WebInStats In-App Marketing SDK Flutter plugin.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on webinstats_flutter_plugin