redlink_flutter_sdk 1.0.0-dev.1
redlink_flutter_sdk: ^1.0.0-dev.1 copied to clipboard
Flutter plugin for Redlink
Redlink for Flutter #
A Flutter plugin to use the Redlink Push Notifications.
Getting started #
To use this plugin, add redlink_flutter_sdk as a dependency in your pubspec.yaml file.
Example project #
Check out the example directory for a sample app and see how to integrate Redlink Push Notifications.
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
Gradle setup
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.
Notification Service Extension
If you want your app to receive some extra media content like images you need to incorporate Notification Service Extension target to your project. To do so simply follow these steps:
- In Xcode select
File->New->Target - Select
Notification Service Extensionand pressNext - Fill in
Product Namewithproject_nameNotificationServiceExtension(changeproject_nameto name of your project) - 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 project_nameNotificationServiceExtension: RedlinkNotificationServiceExtension {
// Do nothing, Redlink will do all the job
}
Dart/Flutter Integration #
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();
Push notifications
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.
_redlinkMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
},
);
Note: configure should be called the very first moment your application should start receiving notifications as early as possible.
User Identification
In order to update information about user use _redlinkMessaging.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