daybook_subscriptions 0.10.1
daybook_subscriptions: ^0.10.1 copied to clipboard
Purchases for Flutter on Daybook: StoreKit 2 and Google Play Billing subscriptions that are never lost, access you can check, and paywalls as data.
0.10.1 #
- For a customer the app signed in, what the store already holds is sent to Daybook once: at the launch that knows the
customer, and right after
identify(PM-B-0308). A subscription bought with another SDK, such as Adapty, and finished or acknowledged there used to reach Daybook only throughrestorePurchases, so an app moving off that SDK showed such a subscriber no access until they restored. Now Daybook holds it at the first launch, andprofileUpdatestells the profile it brings. - On iOS, StoreKit's current entitlements are read as they stand, without
AppStore.sync(): nobody is asked for their Apple ID. On Android, the subscriptions Google Play lists acknowledged; the unacknowledged ones and one-time purchases were reported at launch already. - Each purchase goes once per customer. One that cannot be sent is asked of the store again at the next launch, not kept on disk. Nothing is finished or acknowledged again.
- An anonymous install sends nothing it did not buy: under a Transfer policy the purchase would move to it.
0.10.0 #
Breaking. Purchases are now a module of Daybook (PM-R-0110): the app starts Daybook once, and this SDK is activated with it.
- The app no longer calls
activate. Adddaybookbesidedaybook_subscriptions, callawait Daybook.initialize('dbk_…')with the app's key from the console, and reach purchases asdaybook.subscriptions.Finishing.manualis set withDaybookSubscriptions.configure(finishing:)before Daybook starts. - Sign a person in with
daybook.identify(userId, email:, name:)and out withdaybook.reset(). Every Daybook module hears it; the email and name are kept on the customer. - The install id is the core's, the same one analytics sends. An install that already has an id keeps it.
- The activation and identify carry the id the person's analytics events are filed under, so a purchase made before sign-in is the same person in Analytics as the install's events.
- The app's key,
dbk_…, travels inX-Daybook-Key. Apms_…key still travels inX-Sdk-Key. - With Daybook out of reach at the first launch, the module is still there: the first call that needs a customer activates again.
0.9.0 #
- Who the customer is:
setAttributes,setEmailandsetNamewrite the install's own customer's email, name and the app's own attributes to Daybook (POST /subs/v1/attributes). A null removes a key; keys not named stay. The profile carries them asemail,nameandattributes, and is told onprofileUpdates. - Limits, refused whole as
validation_failednaming the limit: at most 50 of the app's own attributes, keys of up to 40 letters, digits and_, values of up to 500 characters, an email of up to 254. - A profile from a Daybook before attributes reads as none:
emailandnamenull,attributesempty.
0.8.0 #
- One-time products on Google Play. An id with no base plan, such as
lifetime_99, is a one-time product:getProducts,getPaywallProductsandmakePurchasetake it as they takeproductId:basePlanId. Itstypeisunknown, as Google does not say whether it is consumed. - A product Daybook's catalog declares Consumable is consumed once Daybook holds it, so it can be bought again; anything else is acknowledged. Finishing manually,
finishTransactiondoes the same. - At every launch the one-time purchases Google Play still lists are reported, and
restorePurchasesreports them too. - While Daybook cannot be reached, a one-time purchase grants its level on the device as a lifetime one.
0.7.0 #
- Plan changes on Google Play:
makePurchase(product, replacing: SubscriptionReplacement(oldProductId, mode: …))switches the account's subscription ofoldProductIdtoproduct. The modes are Google'sReplacementMode:withTimeProration(the default),chargeProratedPrice,chargeFullPrice,withoutProrationanddeferred. The SDK finds the old purchase itself and asks Play Billing 9.1 for the change. A deferred change, which Play hands over under the old product until it takes effect, is reported all the same. iOS ignoresreplacing, as StoreKit changes plans within a subscription group itself. - A plan change carries the account ids the old purchase was bought with, as Play refuses any other, even when another SDK, such as Adapty, bought it.
- New error code:
subscription_not_found, when the account holds no subscription ofoldProductId.
0.6.0 #
- Android, on Google Play Billing 9.1 (minSdk 24), behind the same Dart API. Subscriptions only, so far.
- A subscription is named by Google Play's product and base plan,
productId:basePlanId, as Daybook's catalog and paywalls name it.getProductsgives its price and period, and as its intro offer the offer Google Play lets this buyer have, such as a free week. makePurchasecarries the customer's id as the purchase's obfuscated account id. A purchase is acknowledged only once Daybook holds it; until then its token waits on disk and is sent again with backoff, as on iOS. Withfinishing: Finishing.manual,finishTransactionacknowledges it. A purchase Daybook refuses is never acknowledged.- At every launch the subscriptions Google Play holds unacknowledged are reported;
restorePurchasesreports all of them. getStorefront()gives Google Play's country, alpha-3 as on iOS (USA), with its alpha-2 code as the id.- Placements are asked for with
store=play_store, so paywalls come by Google Play's ids. Bundle the Android fallback file: Subscriptions › Paywalls › Fallback file · Android. - While Daybook cannot be reached, what Google Play says the account owns is granted on the device, marked
isLocal.
0.5.0 #
getStorefront()gives the App Store storefront the buyer is signed into: its country (USA,BLR) and id, or null when the App Store cannot say. Prices already follow it; copy, a highlighted product or an offer by country can now too.- Every
getPlacementsends the storefront's country to Daybook, which takes it and does not read it yet, so paywalls by country can come later without an app release.
0.4.0 #
- Paywalls.
getPlacement(id)gives the placement's published paywall: its products in order, with the access level each unlocks, and its remote config for the device's language. It keeps the answer for when Daybook cannot be reached, and falls back to the file given tosetFallback(asset).Paywall.sourcesays which answered. getPaywallProducts(paywall)gives the App Store's products for it, in its order, with their intro offers and the buyer's eligibility, and lists inmissingany the App Store did not return.- A purchase of a paywall's product reports the paywall and its placement, also when it is sent again later.
logShowPaywall(paywall)records a view. - A paywall's products teach offline access which level they unlock.
- New error code:
invalid_fallback.
0.3.0 #
- Access keeps working when Daybook does not. While Daybook cannot be reached, the subscriptions and one-time purchases StoreKit holds are granted on the device, for the products Daybook has named to this install, and marked with
AccessLevel.isLocal. Once Daybook answers again, its profile replaces the local one. - A purchase made while Daybook cannot be reached now succeeds with that local grant, and is reported once Daybook is back. A consumable, or a product Daybook has never named, still fails with the network error and waits.
- Offline, a kept level whose expiry has passed reads inactive unless StoreKit still holds it. An unverified transaction is never granted on the device.
0.2.0 #
- Purchases on StoreKit 2.
getProductsgives the App Store's products with their price, type and period;makePurchasebuys one and returnsPurchaseSuccesswith the profile,PurchaseUserCancelledorPurchasePending. Every purchase carries the customer's id as itsappAccountToken. - From
activateon, StoreKit's updates are reported to Daybook as they come, and what it left unfinished is reported at every launch. A Pending purchase that completes later reaches the app throughprofileUpdates. - A transaction is finished only once Daybook holds it. Until then its report waits on disk and is sent again with backoff, from 5 seconds up to 10 minutes. With
finishing: Finishing.manualthe app finishes transactions itself, withgetUnfinishedTransactionsandfinishTransaction. restorePurchasessends everything StoreKit holds for the Apple ID and returns the profile.- New error codes:
transaction_refused,product_not_found,store_error,transaction_not_found.
0.1.0 #
DaybookSubscriptions.activateregisters the install with Daybook and settles the customer it acts as. With Daybook out of reach, an install that has a customer from before goes on as that customer, with the profile it kept.getProfile,profileUpdates,identifyandlogout. The profile comes as typed models: access levels, purchases, andisActive(level).- Errors come as
DaybookSubscriptionsException, with Daybook's own code.