klaviyo_flutter 0.0.1
klaviyo_flutter: ^0.0.1 copied to clipboard
Flutter plugin for Klaviyo integration. Provides push messaging and Klaviyo analitics services
klaviyo_flutter #
Flutter wrapper for Klaviyo Android, and iOS projects.
- Uses Klaviyo Android SDK Version
1.0.0
. - The minimum Android SDK
minSdkVersion
required is 23. - Uses Klaviyo iOS SDK Version
2.0.1
. - The minimum iOS target version required is 13.
Usage #
Import package:klaviyo_flutter/klaviyo_flutter.dart
and use the methods in Klaviyo
class.
Example:
import 'package:flutter/material.dart';
import 'package:klaviyo_flutter/klaviyo_flutter.dart';
void main() async {
// initialize the flutter binding.
WidgetsFlutterBinding.ensureInitialized();
// initialize the Klaviyo.
// make sure to add key from your Klaviyo account public API.
await await Klaviyo.instance.initialize('apiKeyHere');
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text('Send Klaviyo SUCCESSFUL_PAYMENT event'),
onPressed: () async {
await Klaviyo.instance.logEvent(
'\$successful_payment',
{'\$value': 'paymentValue'},
);
},
);
}
}
See Klaviyo Android and iOS package documentation for more information.
Android #
Permissions:
<uses-permission android:name="android.permission.INTERNET" />
Optional permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission
android:name="android.permission.VIBRATE" /><uses-permission
android:name="android.permission.POST_NOTIFICATIONS" />
Enable AndroidX + Jetifier support in your android/gradle.properties file (see example app):
android.useAndroidX=true
android.enableJetifier=true
iOS #
Make sure that you have a NSPhotoLibraryUsageDescription
entry in your Info.plist
.
Push notifications setup #
This plugin works in combination with
the firebase_messaging
plugin to receive Push
Notifications.
Prerequisites: #
- Firebase account
- Familiarity with Firebase documentation.
KlaviyoPushService #
The Klaviyo Push SDK for Android works as a wrapper around FirebaseMessagingService
so the
setup process is very similar to the Firebase client documentation linked above.
You should follow all other setup recommendations from the FCM documentation.
To specify a notification icon, add the following metadata to your app manifest.
Absent this, the application's launcher icon will be used.
<meta-data android:name="com.klaviyo.push.default_notification_icon"
android:resource="{YOUR_ICON_RESOURCE}" />
final firebaseMessaging = FirebaseMessaging.instance;
final token = Platform.isIOS
? await firebaseMessaging.getAPNSToken(): await
firebaseMessaging.getToken
();
if
(
token != null && token.isNotEmpty) {
Klaviyo.instance.sendTokenToKlaviyo(token);
}
Now, if either Firebase direct (e.g. by your own backend server) or Klaviyo sends you a message, it will be delivered to your app.