Conscent Plugin for developers
This is a step by step guide to include Conscent Plugin in your app. This plugin is developed in Flutter and supports both Android and IOS Device.
Step-1
Use our plugin package as a library
Step-2
In your application pass client_id, Environment Mode to be used in your app as below sample:
ConscentInitializer("your_client_id", MODE.SANDBOX);
- ClientId will be received when you would create a ConsCent account, login to client.conscent. In to get access to your clientid
- Mode can be set as MODE.SANDBOX MODE.PRODUCTION. It is used for configuration testing of different environments available.
Mode is used for configuration testing of different environments available.
Step-3
To login into Conscent you need to pass token (token you get from api {{BASE_URL}}/client/generate-temp-token
)
and email or phone number. You receive 2 arguments after login method
- Success {status, userId}
- failure {status, message}
String redirectUrl = await ConscentMethods()
.prepareAutoLoginUrl([(token.text),(phone.text),(email.text)]);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewDefaultApp(
redirectUrl: redirectUrl)
),
).then((value) {
print("response $value");
if (value != null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('$value'),
));
}
});
To logout from Conscent you need to call ConscentMethods().userLogOut()
TextButton.icon(
// <-- TextButton
onPressed: () async {
String? logout = await ConscentMethods().userLogOut();
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('${logout}'),
));
// logOut();
},
icon: const Icon(
Icons.logout,
size: 24.0,
),
label: const Text('Logout'),
),
Step-4
To check if an content is free/paid or a payment needs to be done, in your class, use as below sample: Parameters detail can be checked below for more information.
Payment Formats for User
Login to ConsCent from the Paywall, verify your credentials and then purchase access to premium content. There are three types of payments:
- CONTENT: Pay-per-use is a system in which users are charged only for the specific premium content they want access to.
- PASS: Gives access to user for all the premium content from 1hr to 14 days, which can be changed from ConsCent’s dashboard.
- SUBSCRIPTION: Gives user access to all the premium content starting from 1 month.
ConscentInitializer.setContentId('your_content_id');
ConscentMethods().getContentAccess()
- FutureBuilder<ContentAccessModel?>(
future: ConscentMethods().getContentAccess(),
builder: (context, snapshot)
........
child: Paywall((response) {
if (responseData != null &&
responseData.signature != null) {
showContent = true;
} else {
showContent = false;
}
setState(() {});
(context as Element).reassemble();
})
Subscription
ConscentMethods().getSubscriptionAccess()
FutureBuilder<Subscription_Access?>(
future: ConscentMethods().getSubscriptionAccess(),
builder: (context, snapshot)
............
child: SubscriptionPaywall((response)
- It is async method use to check if a content is purchased or a payment needs to be done.
- You would have to check if
snapshot.data.signature
exists to give access to users for any Prenium Content, otherwise conscent will intialize a paywall.
Parameters detail
- Content id: This will be your content id for which detail needs to be checked.
Premium Content Registration
Whenever you're utilising the ConsCent APIs - you to update the API_URL variables based on the environment you're operating in.
This endpoint allows the Client to Register their Content on ConsCent - with the Content Title, ContentId, Content URL, Tags, Analytics Pixels (Facebook and Google), Price as well as any specific Price Overrides for a country - In order to set a different price for the content in the relevant country. Moreover, the ContentType field is optional - and if no 'contentType' is provided then the default 'contentType' of the client will be treated as the 'contentType' of the content being registered. While category based pricing can be used for any content, by passing the priceCategory field on registering the content - as long as the price category has been registered by the client on the ConsCent dashboard along with its respective price, duration and priceOverrides; however, category based pricing only comes into effect if the content does not have a pre-determined price field (price must be null).
HTTP Request
POST {API_URL}/api/v1/content
Authorization
Client API Key and Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.
Request Body
Parameter | Default | Description |
---|---|---|
contentId | required | Content Id by which the Content has been registered on the Client CMS. Please ensure that the content ID is at most 32 characters and can only contain letters, numbers, underscores and dashes. |
title | required | Title of the Content |
price | optional | Content Price for pay-per-use pricing |
currency | optional | Currency in which price is determined. Must be an ISO 4217 supported - 3 Digit currency Code. INR is used as the default if no value is provided. |
url | required | URL where the content is available on your website |
duration | optional | Free content access time for user once the user has purchased the content. (Standard Practice - 1 Day); |
authorId | optional | Id of the Author of the content - Mandatory if authorName is present |
authorName | optional | Name of the Author of the content |
contentType | optional | Must be an ENUM from one of the following - STORY, VIDEO, SONG, PODCAST, PREMIUM CONTENT |
priceOverrides | optional | Price Overrides for any particular country with the relevant country code as the name and the ENUM value in the price. The country code list is located the end of this document |
download | optional | Object containing the "url", "fileName" and "fileType". All download parameters must be provided if the content is downloadable on purchase. Also, the "fileType" is an ENUM and only accepts "PDF" currently. |
priceCategory | optional | The priceCategory of the content, which has been registered by the client on the ConsCent Client Dashboard - in order to invoke category based pricing (only valid if story doesn't have a price). Each registered priceCategory will have an associated price, currency, duration and priceOverrides. |
pixels | optional | A nested object with the optional keys being "facebook" and "google". With the "google" object only requiring the trackingId - to include the gtag throughout the platform. However, for the "facebook" object the "pixelId" must be passed along with an "events" array - containing the event name (as configured on the facebook events manager), the eventType (which is an ENUM to be chosen from "VIEW", "CONVERSION" ) as well as any data/values associated with the particular event. |
tags | optional | Array of tags associated with the content |
Libraries
- conscent_initializer
- conscent_methods
- constants
- coreDb
- data
- datamodel/api_mode
- datamodel/auto_login_response
- datamodel/content_access_data_post
- datamodel/content_access_model
- datamodel/content_access_post
- datamodel/content_accesses_post
- datamodel/content_details
- datamodel/content_details2
- datamodel/data_file
- datamodel/embedded_model
- datamodel/embedded_subscribtion
- datamodel/getuser_detail
- datamodel/login_challenge_post
- datamodel/login_challengeget
- datamodel/logout
- datamodel/page_view_event
- datamodel/paywall_click_event
- datamodel/paywall_config
- datamodel/paywall_view_event
- datamodel/subscription_access_model
- defaultSubscribtion
- embedded_subscribe
- extra
- flutter_conscent_plugin
- flutter_conscent_plugin_method_channel
- flutter_conscent_plugin_platform_interface
- flutter_conscent_plugin_web
- generated_plugin_registrant
- paywalls/flutter_flow/custom_functions
- paywalls/flutter_flow/flutter_flow_checkbox_group
- paywalls/flutter_flow/flutter_flow_theme
- paywalls/flutter_flow/flutter_flow_util
- paywalls/flutter_flow/flutter_flow_widgets
- paywalls/flutter_flow/internationalization
- paywalls/flutter_flow/lat_lng
- paywalls/flutter_flow/local_file
- paywalls/flutter_flow/nav/serialization_util
- paywalls/flutter_flow/place
- paywalls/in_article_8_a_1_c_t_a/in_article8_a1_c_t_a_widget
- paywalls/in_article_50pageblock_3_a_3_c_t_a/in_article50pageblock3_a3_c_t_a_widget
- paywalls/inarticle_5_a_3_c_t_a/inarticle5_a3_c_t_a_widget
- paywalls/inarticle_7_a_1_c_t_a/inarticle7_a1_c_t_a_widget
- paywalls/inarticle_8_a_2_c_t_a/inarticle8_a2_c_t_a_widget
- utils/slicedTextComponent
- utils/utils
- web_view_default
- webviews