Pushe class
@author Mahdi Malvandi Main plugin class handling most of SDK's works.
Constructors
- Pushe()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addTags(
Map< String, String> tags, {Function? callback}) → Future<void> -
Add tags.
tags
key-value pairscallback
is an optional function that will be called with result of adding tags. -
createNotificationChannel(
String channelId, String channelName, {String? description, int? importance, bool? enableLight, bool? enableVibration, bool? showBadge, int? ledColor, List< int> ? vibrationPattern}) → Future<void> - Creates a channel using native API. Read more about channel at https://developer.android.com/training/notify-user/channels You can send notifications through only one channel, so users that have created that channel in their devices, can receive it, while rest of them can not. For android versions lower than 8.0 (API 26), this method has no function
-
disableCustomSound(
) → Future< void> - Custom sound is enabled by default. If you wanted to disable it and use the default sound (like for avoiding downloading sound) you can disable it.
-
disableNotificationForceForegroundAware(
) → Future< bool> -
Disables the behaviour set by
enableNotificationForceForegroundAware
-
enableCustomSound(
) → Future< void> - Custom sound is enabled by default. However, if you have turned it off, you can revert it using this function
-
enableNotificationForceForegroundAware(
) → Future< bool> - Enables force to avoid displaying notification when the app is open Instead only listeners will be called
-
getActiveService(
) → Future< String> -
@return either
hms
orfcm
or empty result if none of them were available. NOTE: If anything was wrong in initialization, this may never return result -
getAdvertisingId(
) → Future< String> - Return GoogleAdvertisingId (if using FCM) or AOID (if using HMS)
-
getAndroidId(
) → Future< String> -
getCustomId(
) → Future< String> - Get custom id
-
getDeviceId(
) → Future< String> - Get the unique id of the devices Returns empty if native returned null
-
getFcmToken(
) → Future< String> - @return Token of Firebase cloud messaging used by Pushe and empty if anything was wrong or active service wasn't FCM
-
getGoogleAdvertisingId(
) → Future< String> - Get google advertising id
-
getHmsToken(
) → Future< String> - @return Token of Huawei PushKit used by Pushe and empty if anything was wrong or active service wasn't HMS
-
getSubscribedTags(
) → Future< Map> - Get subscribed tags
-
getSubscribedTopics(
) → Future< List> - Get subscribed topics
-
getUserConsentStatus(
) → Future< bool> - Get the user consent status
-
getUserEmail(
) → Future< String> - Get email
-
getUserPhoneNumber(
) → Future< String> - Get user phone number
-
initialize(
) → Future< void> - GDPR related You can use this function after getting user consent to initialize pushe lib for ios only: you must call this function in order to pushe to start working
-
isCustomSoundEnabled(
) → Future< bool> - To check whether custom sound is already enabled or not
-
isForceForegroundAware(
) → Future< bool> - Returns true if foreground notification are published by force, false otherwise
-
isInitialized(
) → Future< bool> - Check if Pushe is initialized to server or not.
-
isNotificationOn(
) → Future< bool> - To check whether notification will publish or not (default is true of course)
-
isRegistered(
) → Future< bool> - Check if Pushe is registered to server or not.
-
removeNotificationChannel(
String channelId) → Future< void> - Remove the channel Id that was created For android versions lower than 8.0 (API 26), this method has no function
-
removeTags(
List< String> tags, {Function? callback}) → Future<void> -
Remove tags.
tags
list of tag keys to removecallback
is an optional function that will be called with result of removing tags. -
sendAdvancedNotificationToUser(
IdType type, String id, String json) → Future< void> -
sendEcommerceData(
String name, double price, {String? category, int? quantity}) → Future< void> -
Send ecommerce data.
name
is the name of ecommerce dataprice
is the value of ecommerce name -
sendEvent(
String name, {EventAction action = EventAction.custom, dynamic data}) → Future< void> -
Send an event
name
is the name of event that wants to send Possible option: SendEvent -
sendNotificationToUser(
IdType type, String id, String title, String content, {String? bigTitle, String? bigContent, String? imageUrl, String? iconUrl, String? notificationIcon, dynamic customContent}) → Future< void> -
Sending notification from this device to another device which is registered as a user of this app.
type
is the type of unique id which you are passingid
is the id of the typetype
title
is the title of the notificationcontent
is the content of the notificationbigTitle
is the complete title of the notificationbigContent
is the complete content of the notificationimageUrl
is the url of the image which notification can containiconUrl
is the url of the notification iconcustomContent
is the custom json you send along with the notification message which can be received as the notification customContent in the target device -
setCustomId(
String id) → Future< void> - Set custom id
-
setInitializationCompleteListener(
Function callback) → Future< void> - Call it's callback when initialization is completed
-
setNotificationListener(
{dynamic onReceived(NotificationData?)?, dynamic onClicked(NotificationData?)?, dynamic onDismissed(NotificationData?)?, dynamic onButtonClicked(NotificationData?)?, dynamic onCustomContentReceived(dynamic)?, dynamic onBackgroundNotificationReceived(String, dynamic)?}) → Future< void> -
Set callbacks for different types of events for notifications (in foreground or when app is open in the background)
onReceived
is called when notification was received.onClicked
is called when notification was clicked.onDismissed
is called when notification was swiped away.onButtonClicked
is called when notification contains button and a button was clicked.onCustomContentReceived
is called when notification includes custom json. It will a json in string format.onBackgroundNotificationReceived
is the function that will be called when notification is received in the background, this would be a TopLevel or Static function will be passed and saved for later usage. Function will take a dynamic value which is a dictionary (aka Map), which contains 'type' (one of receive, click, button_click, custom_content, dismiss), and the 'data' either a custom map (provided as customContent), the notification, or the notification and the button (in case of button click) In addition, the Isolate of the top level function is different and it will not have access to any widget (if app is in foreground, this does not get called and instead foreground function will take place). So be aware of the isolate difference. -
setNotificationOff(
) → Future< void> - If this function is called, notification will not be shown.
-
setNotificationOn(
) → Future< void> - Default of notification is set to On, if you have set it off, you can revert it using this function.
-
setRegistrationCompleteListener(
Function callback) → Future< void> - Call it's callback when registration is completed
-
setUserConsentGiven(
bool enabled) → Future< void> -
GDPR related
If user gave consent for collecting necessary extra data for Analytics.
Simply call this function with True parameter
the related task will be scheduled right away and will collect when needed.
If for any reason user decided to undo his dialog action, or for some other reason, you wanted to cancel consent,
Simply call this function with False parameter
enabled
enable or disable user consent for collecting extra data -
setUserEmail(
String email) → Future< void> - Set email
-
setUserPhoneNumber(
String phone) → Future< void> - Set user phone number
-
subscribe(
String topic, {Function? callback}) → Future< void> -
Subscribe to a topic.
topic
is the name of that topic. The naming rules must follow FCM topic naming standards.callback
is an optional function that will be called with result of subscription. -
unsubscribe(
String topic, {Function? callback}) → Future< void> -
Unsubscribe from a topic already subscribed.
topic
is the name of that topic. The naming rules must follow FCM topic naming standards.callback
is an optional function that will be called with result of Unsubscription.
Constants
- customContentReceived → const String
- notificationButtonClicked → const String
- notificationClicked → const String
- notificationDismissed → const String
- notificationReceived → const String