Flutter SDK

Comprehensive reference of iZooto's SDK methods for Android & iOS.

📘

Just starting with Flutter?

Check out our Flutter SDK Integration guide.

Parameter

Data Type

Description

Initialisation

init

Builder Method

Initialises iZooto to register the device for push notifications. Should be called in the AppState class of your main.dart file.
See Flutter SDK Setup for details and code examples.

User Permission

setSubscription

Method

Disables iZooto from sending notifications to the current device.

Notifications Handler

onNotificationReceived

Handler

Called when a notification is received by a device.

onNotificationOpened

Handler

Called when the notification is clicked by the user.

WebView Handler

onWebView

Handler

To open Landing URL inside your app's activity

Appearance

setBadgeCount

Method

ONLY FOR IOS - Customize the badge count displayed on the app icon.

Sound

setNotificationSound

Method

Customize the sound that gets played whenever a notification is received on the device.

Analytics

setFirebaseAnalytics

Method

Send events to Google Analytics to track your campaign performance.

Android Tags

addTag

Method

Use this method to tag a users to a specific value.

removeTag

Method

User this method to remove already tagged users from a value.

Get Tags List
REST: GET API

API

Get a list of all the tags that you have created for you app along with the number of users inside that tag.

Send Campaigns to Tagged Users
REST: POST API

API

Use this to send out notifications to only your tagged users.



Initialization

init

Initialises iZooto to register the device for push notifications. Should be called in the AppState class of your main.dart file. See Flutter SDK Setup for details and code examples.

Future<void> _iZootoInitialise() async {
  iZooto.androidInit(); // for Android
}


User Permission

setSubscription

Method

Can be used to not deliver notifications to a specific device. This method does not officially subscribe or unsubscribe users from the app settings, it unsubscribes them from receiving a push from iZooto.
You can call this method with false to opt-out users from receiving notifications through iZooto. You can pass true later to opt users back into notifications.

The below snippet needs to be added to the main.dart file of the code.

iZooto.setSubscription(false);


Notification Handlers

Implement Notification Handlers to send and receive data when a notification is received or clicked,

onNotificationReceived

Handler

Fires when a notification is received. It will be fired when your app is in focus or in the background.

The following snippet goes in the main.dart file.

iZooto.shared.onNotificationReceived((payload) {
    print('iZooto Flutter Paylaod : $payload ');
    List<dynamic> list = json.decode(payload);
    print(list.toString());
    List<String> receivedpayload = list.reversed.toList();
    print(receivedpayload);
  });

onNotificationOpened

Handler

Use to process an iZooto notification the user just tapped on.

Add the below code snippet in the main.dart file.

iZooto.shared.onNotificationOpened((data) {
    print('iZooto DeepLink Datadata : $data');
  });


WebView Handler

onWebView

Handler

This method can be used to override iZooto's Landing URL and directly open them inside your app's WebView. No explicit notification handler code is required and you would not have to define additional key: value pairs to do so.
Using this will significantly reduce the campaign creation time.

Add the below code snippet in the main.dart file.

iZooto.shared.onWebView((landingUrl) {
    print(landingUrl);
    print('iZooto Landing URL  : $landingUrl');
  });


Appearance

setBadgeCount

Method

Used to set a custom badge count to be displayed on the app icon on the device. By default, the notification count is set as incremental.

This can be modified to a static number by using the below method:

func applicationDidBecomeActive(_ application: UIApplication) {
  application.applicationIconBadgeNumber = 0
  iZooto.setBadgeCount(badgeNumber: 1)
}

Add the below code to the SceneDelegate.swift file to ensure the above method works with all iOS versions;

@available(iOS 13.0, *)
func sceneDidBecomeActive(_ scene: UIScene) {
  UIApplication.shared.applicationIconBadgeNumber = 0
  iZooto.setBadgeCount(badgeNumber: 1)
}

@available(iOS 13.0, *)
func sceneWillEnterForeground(_ scene: UIScene) {
  UIApplication.shared.applicationIconBadgeNumber = 0
  iZooto.setBadgeCount(badgeNumber: 1)
}

🚧

Pass 0 in the setBadgeCount method to default to an incremental value.



Sound

setNotificationSound

Method

Used to set a custom sound to the notifications when delivered on the device. The device's usual notification sound is played by default, which can be overridden to use a custom sound for your app.

Add the below code to the respective classes to enable this feature:

iZooto.setNotificationSound("Sound_File_Name");
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "Sound_File_Name_with_Extension"))
self.bestAttemptContent.sound = [NSString stringWithFormat:@"Sound_File_Name_with_Extension", self.bestAttemptContent.sound];

🚧

Points to Note

  • The notifications sound file should already be present in the project directory.
  • Supported file types are .mp3 and .wav.
  • The file name needs to be passed without the file extension for Android and with the file extension for iOS.


Analytics

setFirebaseAnalytics

Method

iZooto will automatically send notification events to your analytics dashboard if Google Analytics for Firebase is correctly implemented.

Events
The iZooto SDK tracks events that pertain to notification open & receive events. The following events are sent:

Event Name

Purpose

push_notification_opened

An iZooto notification was opened

push_notification_received

An iZooto notification was received.

push_notification_influence_open

An application was opened within 2 minutes of an iZooto notification being received.

The iZooto SDK also sends parameters that contain more info about the particular notification the event is attributed to. These can be directly defined when you create a campaign.

Parameter Name

Purpose

source

To attribute this event's source to the iZooto SDK

medium

A formal indication that the medium for the event is a notification.

campaign

By default, it would be your campaign name.

term

Can be used to track keywords

content

Can be used to differentiate between links that point to the same URL.

Follow the Firebase integration documentation and verify that Firebase is correctly functioning inside your application.

Once everything is set up, use the following code snippet in the App.js file to enable passing events to Firebase.

iZooto.setFirebaseAnalytics(true);

👍

You're Done!

Google Analytics for Firebase is now set up to receive iZooto events.




Did this page help you?