Additional Methods Dart
Optionals Methods Dart
SDK Invocation and Functions
Note: The <variant> tag needs to be replaced with the variant provided by Siprocal.
Initialize the Siprocal SDK in main.dart by creating an instance of siprocalplugin:
import 'package:siprocalsdk_<variant>/siprocalsdk_<variant>.dart'; //example for Helios variant => import 'package:siprocalsdk_helios/siprocalsdk_helios.dart';
final _siprocalPlugin = Siprocalsdk<variant>();// example for Helios variant => final _siprocalPlugin = SiprocalsdkHelios();
Common methods for Android and iOS
Custom Org Selection (Optional):
If the client wishes to make the same app available for different organizations, they can achieve this by calling the following API to the Siprocal SDK.
_siprocalPlugin.setCountryCodeSelected(cc);
Opt-In/Opt-Out Settings:
The host application can provide an option to the users to Opt-In and Opt-Out of the Ads services. The same can be accomplished via the following methods to access or update the Status.
The method accepts boolean value. When TRUE is passed, the user is Opted-In to the Ad services and when FALSE is passed, the user is Opted-Out of the Ad Service.
To update Opt-In status:
_siprocalPlugin.updateOptIntStatus(value);
To get Opt-in status:
bool? status = await _siprocalPlugin.getOptIntStatus();
ClientAttributes:
In some cases, the Host application may need to pass attributes to the Siprocal SDK. This is supported with the ClientAttributes class provided as a part of the SDK.
Note: Avoid Data Override: Please note that all values need to be passed together to the SDK before the setClientAttributes method is called. Calling the method multiple times will overwrite the previous data, and only the new value will be available and sent to Siprocal servers.
The following code snippet shows how this can be done.
void setClientAttributes() {
Map<String, dynamic> parameters = new Map();
parameters["NAME_ATTRIBUTE"] = "VALUE";
parameters["NAME_ATTRIBUTE"] = "VALUE";
_siprocalpluginPlugin.setClientAttributes(parameters);
}
The following are the keys which we have pre-defied.
- Phone number - "PHONE_NUMBER"
- Carrier - "CARRIER"
- Bill type - "BILL_TYPE" // POSTPAY or PREPAY.
In addition to the keys above you are free to add your own keys, Siprocal would be storing the information in DB for future reference.
Methods available for Android
Enable/Disable capture of Sensitive Data:
Capturing sensitive data requires a prominent disclosure, and the user must consent to the app's data capture and usage. If the user consents, the app should send a boolean flag using the following method:
void _handleSensitiveData(bool value) {
_siprocalPlugin.setSensitiveData(value);
}
Turn ON/OFF the SDK:
If you want to handle the turning on and off of the SDK, add the method activeSDKManually() to the SiprocalSDKSettings:
Note: The SDK by default is OFF, you need use setSDKStatus for Turn On the SDK.
That way you can then use the following method to turn it on/off:
void _handleStatusSDK(bool value) {
_siprocalPlugin.setSDKStatus(value);
}
Notification Channel
If you need to know information about the SDK notification channel you can use the following methods.
String? channelId = await _siprocalPlugin.getNotificationChannelId();
String? channelName = await _siprocalPlugin.getNotificationChannelName();
FCM Push Integration (Optional)
If you already have FCM Integration into your project, you need to create the methods for firebase:
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
await Firebase.initializeApp();
String id;
id = await _siprocalpluginPlugin.getFCMSenderId() ?? "Unknown";
if (Platform.isAndroid && message.from == id) {
_siprocalpluginPlugin.handleFCMMessage(message.data);
}
}
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(const MyApp());
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
listenFCM();
getToken();
//other methods
}
void listenFCM() async {
String id;
id = await _siprocalpluginPlugin.getFCMSenderId() ?? "Unknown";
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
if (Platform.isAndroid && message.from == id) {
_siprocalpluginPlugin.handleFCMMessage(message.data);
}
});
}
void getToken() async {
await FirebaseMessaging.instance.getToken().then((token) {
setState(() {
print("token: $token");
// saveToken = token;
_siprocalpluginPlugin.refreshToken();
});
});
}
}
Methods available for iOS:
Request Push Notification Permission:
_siprocalPlugin.requestPushPermission();
App Tracking Permission:
Siprocal SDK needs to request App Tracking permission from the user to collect IDFA details and track user activity on DR Platform. Below is the sample code to invoke the same from any View Controller class.
_siprocalPlugin.requestAppTracking();
Updated 6 months ago