airbridge_flutter_sdk 4.1.2 airbridge_flutter_sdk: ^4.1.2 copied to clipboard
Airbridge SDK for Flutter.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:airbridge_flutter_sdk_example/app.dart';
import 'package:airbridge_flutter_sdk_example/basic/utility/storage.dart';
import 'package:airbridge_flutter_sdk_example/basic/import.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
initFirebase();
runApp(App());
init();
}
Future<void> initFirebase() async {
await Firebase.initializeApp();
String? token;
if (Platform.isAndroid) {
token = await FirebaseMessaging.instance.getToken();
print("[App] token : ${token ?? 'token NULL!'}");
} else if(Platform.isIOS) {
token = await FirebaseMessaging.instance.getAPNSToken();
print("[App] apns : ${token ?? 'apns NULL!'}");
}
if (token != null) {
Airbridge.registerPushToken(token);
}
}
Future<void> init() async {
Airbridge.setOnDeeplinkReceived((deeplink) {
Storage.set('deeplink', deeplink);
});
Airbridge.setOnAttributionReceived((result) {
Storage.set('attribution', result);
});
}