webinstats_flutter_plugin

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

webinstats flutter plugin

webinstats #
A Flutter plugin to integrate webinstats SDK in your Flutter app.
Getting Started #

Add the latest version of the package in your pubspec.yaml
For iOS go to the ios folder and run pod install
import 'package:webinstats_flutter/webinstats_flutter.dart';
For Android You should add below to ~/android/app/src/main/AndroidManifest.xml

<uses-library android:name="org.apache.http.legacy" android:required="false"/>
copied to clipboard
Available Methods #

execute
addItem
createEvent
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());
}

copied to clipboard

Add webinstats dependency to the app/build.gradle inside android :

dependencies {
`implementation 'com.github.WebInStats:android_wis:3.0.55@aar'`
}

copied to clipboard

- 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>

copied to clipboard

Add the maven { url 'https://jitpack.io' } in the android/build.gradle

allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
copied to clipboard

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'
},
),
),
copied to clipboard
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);
}
copied to clipboard
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;
copied to clipboard

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;
}

copied to clipboard

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];
}
copied to clipboard
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
[Webinstats registerWithDeviceTokenWithDeviceToken:deviceToken];
}
copied to clipboard
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',
),
),

copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.