sourcepoint_unified_cmp_flutter_webview_extension

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

sourcepoint unified cmp flutter webview extension

sourcepoint unified cmp - flutter webview extension #

This is integrating the flutter integration for sourcepoint's unified CMP with the webview_flutter package.
This package provides a single extension method preloadConsent() to the WebViewController to inject the
consent given in "flutter land" into the webview.
Contributing to the project #
Please the CONTRIBUTING.md for details.
example usage: #
In order to use this extension please make sure to implement sourcepoint_unified_cmp in your project - for further tasks please check the sourcepoint_unified_cmp package.
sample code: #
For a running examples please check the sample app at example/lib/main.dart - the sample app can be run using melos run run:example:flutter_webview -- -d sdk (android) or melos run run:example:flutter_webview -- -d IPhone (ios).
Important bits of the implementation are:
Import the sourcepoint unified cmp and the webview_flutter package and the extension to the webview
import 'package:sourcepoint_unified_cmp/sourcepoint_unified_cmp.dart';
import 'package:sourcepoint_unified_cmp_flutter_webview_extension/sourcepoint_unified_cmp_flutter_webview_extension.dart';
import 'package:webview_flutter/webview_flutter.dart';
copied to clipboard
Initialize and configure the sourcepoint controller
final config = SPConfig(
accountId: 22,
propertyId: 31007,
propertyName: 'sdks-auth-consent-test-page',
pmId: '122058',
campaigns: [CampaignType.gdpr],
);

_controller = SourcepointController(config: config)
..setEventDelegate(
SourcepointEventDelegate(
onConsentReady: (SPConsent consent) {
debugPrint('DELEGATE onConsentReady: Consent string: '
'${consent.gdpr?.euconsent}');
},
onSpFinished: (SPConsent consent) {
debugPrint(
'DELEGATE SpFinished: Consent string: ${consent.gdpr?.euconsent}',
);
},
),
);
copied to clipboard
Once a site is loaded in the webview, the consent can be injected using the preloadConsent() method on the WebViewController - consent has to be obtained before using the sourcepoint unified cmp package.
_webViewController
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (String url) {
_webViewController.preloadConsent(consent: consent!);
},
),
)
..loadRequest(
Uri.parse(
'https://sourcepointusa.github.io/sdks-auth-consent-test-page/?_sp_version=4.9.0&_sp_pass_consent=true',
),
);

return WebViewWidget(controller: _webViewController);
copied to clipboard
Important: the web page needs to implement the sourcepoint unified cmp script and the ?_sp_version=4.9.0&_sp_pass_consent=true has to be used in order to instruct the js sdk to listen for external consent.
Result:

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.