redlink_flutter_sdk 1.3.1
redlink_flutter_sdk: ^1.3.1 copied to clipboard
Flutter plugin for Redlink
Redlink Push SDK for Flutter #
About SDK #
A Flutter plugin to use the Redlink Push Notifications.
Getting Started #
Prerequisites #
- Existing Flutter project
- Active Redlink account
Installation #
Android Integration #
To integrate your plugin into the Android part of your app, follow these steps:
Firebase platform integration
Redlink push is based on Firebase platform. To configure it on Android check the documentation
Provide required string resources
Add required tokens to *.xml resources, obtained from the Redlink dashboard.
<string name="redlink_app_id"></string>
<string name="redlink_token"></string>
<string name="redlink_secret"></string>
<string name="redlink_events_token"></string>
Add required Firebase Sender ID, obtained from the Firebase dashboard (Settings -> Cloud Messaging -> Sender ID)
<string name="fcm_sender_id"></string>
SDK initializes automatically, there are no other actions required.
iOS Integration #
Required:
- Valid iOS Push Token
- Physical iOS device (Push services doesn't work in Simulator)
- Redlink account with
AppId,Token,SecretandEvents Token - Application with deployment target equal or above iOS 10.0
Add RedlinkConfig.plist
- Select in Xcode
File->New->File - Under Resource section select
Property List - Fill
SaveAswith nameRedlinkConfig.plistand select Targets (should be both,project_nameandproject_nameNotificationServiceExtension) - Right click on added
RedlinkConfig.plistand selectOpen As->Source Code - Add following code instead of original one
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppId</key>
<string>your_application_id</string>
<key>Token</key>
<string>your_application_token</string>
<key>Secret</key>
<string>your_application_secret</string>
<key>EventsToken</key>
<string>your_application_events_token</string>
</dict>
</plist>
- Replace
your_application_id,your_application_token,your_application_secretandyour_application_events_tokenwith variables obtained from Redlink dashboard.
Add Notification Service Extension (Optional) #
Notification Service Extension gives the app capability to render media content within push notification view in Notification Center.
- In Xcode select
File->New->Target - Select
Notification Service Extensionand pressNext - Fill in
Product NamewithNotificationServiceExtension - Select
SwiftunderLanguagesection (Even if your project is written inObj-C) - Skip Activate scheme alert using
Cancel - Remove a class body generated by Xcode, import Redlink framework and use
RedlinkNotificationServiceExtensionas a superClass. Your extension should now look like this:
import Redlink
class NotificationServiceExtension: RedlinkNotificationServiceExtension {
}
Dart/Flutter Integration #
To use this plugin, add redlink_flutter_sdk as a dependency in your pubspec.yaml file:
dependencies:
redlink_flutter_sdk: ^1.3.1
Usage #
From your Dart code, you need to import the plugin and instantiate it:
import 'package:redlink_flutter_sdk/redlink_messaging.dart';
final RedlinkMessaging _redlinkMessaging = RedlinkMessaging();
User Identification #
In order to update information about user use RedlinkUser.setUser method.
You can change each of the following data fields:
- email
String - phone
String - firstName
String - lastName
String
Validation:
emailrequires valid email formatemail,companyName,firstName,lastNamecan be up to 64 length characters
RedlinkUser.setUser({
firstName: 'User's name',
lastName: 'User's last name',
email: 'User's email address',
phoneNumber: 'User's phone number',
});
User Removal #
There is also possibility to remove all stored user data. To do that call:
RedlinkUser().removeUser()
If you want also to unsubscribe user from Redlink Push Notification Services you can also use additional parameter while removing user like so:
RedlinkUser().removeUser(deletePushToken: true)
If you just want to detach token:
RedlinkUser().detachToken()
Events Creation #
In order to track custom user events use RedlinkAnalytics class. It can be accessed by using trackEvent static method:
static void trackEvent({
@required String eventName,
@required Map<String, dynamic> parameters,
String userData,
})
Each event is identified by eventName property.
You can also provide additional parameters to an event by populating parameters map argument.
Parameters are of type [String: Any] - where Any is String or Int or Bool or Date. Any other type of value will be ignored and removed automatically.
Validation:
EventNamecan be up to 64 length characters Besides paramaters you can injectuserDataas Valid JSON String:
Handling Push Notifications #
General information
Register onMessage callback via _redlinkMessaging.configure() to listen for incoming messages.
This will bring up a permissions dialog for the user to confirm on iOS. It's a no-op on Android.
Deeplinking
Deeplinking works using the official Platform SDK. In order to handle received URL's use:
_redlinkMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
},
);
message will provide information about any information your application might react on by showing additional screen.
Demo application #
Check out the example directory for a sample app and see how to integrate Redlink Push Notifications.