Code Monkey home page Code Monkey logo

purchases-flutter's Introduction

RevenueCat

pub package

purchases_flutter

purchases_flutter is a client for the RevenueCat subscription and purchase tracking system. It is an open source framework that provides a wrapper around StoreKit, Google Play Billing and the RevenueCat backend to make implementing in-app subscriptions in Flutter easy - receipt validation and status tracking included!

Features

RevenueCat
Server-side receipt validation
➡️ Webhooks - enhanced server-to-server communication with events for purchases, renewals, cancellations, and more
🎯 Subscription status tracking - know whether a user is subscribed whether they're on iOS or Android
📊 Analytics - automatic calculation of metrics like conversion, mrr, and churn
📝 Online documentation and SDK Reference up to date
🔀 Integrations - over a dozen integrations to easily send purchase data where you need it
💯 Well maintained - frequent releases
📮 Great support - Help Center

Installation

To use this plugin, add purchases_flutter as a dependency in your pubspec.yaml file.

Requirements

purchases_flutter requires Xcode 14.0+ and minimum targets iOS 11.0+.

SDK Reference

Our full SDK reference can be found here.

Getting Started

For more detailed information, you can view our complete documentation at docs.revenuecat.com.

purchases-flutter's People

Contributors

aboedo avatar beylmk avatar codykerns avatar coreyrab avatar daentech avatar dependabot[bot] avatar devasidmi avatar jazminemt avatar joshdholtz avatar kmurphy-rc avatar korzonkiee avatar loregr avatar markvillacampa avatar mhadaily avatar miguelcarranza avatar mrgnhnt96 avatar mshmoustafa avatar nachosoto avatar natsuonfire avatar pattobrien avatar rcgitbot avatar sdurban avatar sese-schneider avatar sradam avatar taquitos avatar tecbot avatar tiinanguyen avatar tonidero avatar tonycosentini avatar vegaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

purchases-flutter's Issues

com.revenuecat.purchases.common.PurchasesPeriod.parse (PurchasesPeriod.java:125)

Hello,

I started to see the following exception in Crashlytics logs in two devices (Huawei P30 lite, Android 9). How can I solve this? Thank you.

Fatal Exception: java.lang.RuntimeException: Text cannot be parsed to a Period: 365
       at com.revenuecat.purchases.common.PurchasesPeriod.parse(PurchasesPeriod.java:125)
       at com.revenuecat.purchases.common.MappersKt.mapPeriod(MappersKt.java:17)
       at com.revenuecat.purchases.common.MappersKt.mapIntroPrice(MappersKt.java:102)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:101)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:37)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:63)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:63)
       at com.revenuecat.purchases.common.CommonKt$getOfferings$2.invoke(CommonKt.java:7)
       at com.revenuecat.purchases.common.CommonKt$getOfferings$2.invoke(CommonKt.java:2)
       at com.revenuecat.purchases.ListenerConversionsKt$receiveOfferingsListener$1.onReceived(ListenerConversionsKt.java:7)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1$2.invoke(Purchases.java:10)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1$2.invoke(Purchases.java)
       at com.revenuecat.purchases.Purchases.dispatch(Purchases.java:60)
       at com.revenuecat.purchases.Purchases.access$dispatch(Purchases.java)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1.invoke(Purchases.java:46)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1.invoke(Purchases.java:2)
       at com.revenuecat.purchases.Purchases$getSkuDetails$1$1.invoke(Purchases.java:55)
       at com.revenuecat.purchases.Purchases$getSkuDetails$1$1.invoke(Purchases.java:2)
       at com.revenuecat.purchases.BillingWrapper$querySkuDetailsAsync$1$1.onSkuDetailsResponse(BillingWrapper.java:159)
       at com.android.billingclient.api.BillingClientImpl$10$1.run(BillingClientImpl.java:36)
       at android.os.Handler.handleCallback(Handler.java:907)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:216)
       at android.app.ActivityThread.main(ActivityThread.java:7625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

App crash on iOS when calling makePurchase() with non-existing product ID

I noticed that if I call makePurchase(productID) on iOS with a product ID that does not exist in App Store Connect (but that does exist in Google Play Store), the entire app crashes. Usually there is no error message, only a

Lost connection to device.

A few times I've seen this kind of output as well

Failed to send request: {"jsonrpc":"2.0","id":"41","method":"resume","params":{"isolateId":"isolates/707523504"}}
Lost connection to device.

I'm not sure what's going on, but a guess is that something is crashing in the native iOS code? Not sure why it causes the entire app to crash instead of generating a PlatformException though.

This has only happened on iOS, and I'm testing it on an iPad Mini with iOS 12.4. This is the output from flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-SE)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.4)
[✓] Connected device (1 available)

Expose `userDefaults` in `Purchases.configure` just like iOS repo

Problem

The original problem that requires this change, is that RevenueCat uses NSUserDefaults as a data layer. The actual problem is using the default instance and not a separate standalone instance specially instantiated for RevenueCat.

This means when NSUserDefaults is reset/reloaded/cleared, then RevenueCat will lose track of all persisted data.

This might happen automatically for some reason, abnormalities with NSUserDefaults shared instance that puts RevenueCat in an undefined state.

Fix

With this introduction for the problem, the solution is simply taking in an optional string ID as a parameter within Purchases.Configure that would create the standalone NSUserDefaults instance automatically for us. Like this solution in an issue from iOS repo. Or at least just make it so that RevenueCat uses a hardcoded NSUserDefaults domain ID.

Object.noSuchMethod getOfferings

Hey,

if there are no offerings available the current parsing of getOfferings will throw an exception.
We found also that this can happen in production, why we are not sure, possible network issue? If a network error could lead to this as well then this is a second issue because I expect that the native plugin throws a PlatformException with NetworkError code.

Non-fatal Exception: dart:core-patch/object_patch.dart 53 in Object.noSuchMethod
0  ???                            0x0 Object.noSuchMethod + 53 (object_patch.dart:53)
1  ???                            0x0 new Offering.fromJson + 37 (offering_wrapper.dart:37)
2  ???                            0x0 new Offerings.fromJson + 13 (offerings_wrapper.dart:13)
3  ???                            0x0 Purchases.getOfferings + 108 (purchases_flutter.dart:108)

We use version: 1.0.1 of the plugin and Flutter (Channel beta, v1.12.13+hotfix.6)

AdvertisingIdentifier

We have created an app that is in the App store 'made for kids' special category.
The app was rejected due to IDFA being present. Having searched our app it appears this comes from the Revenue Cat plugin.
fgrep -R advertisingIdentifier .
There are entries in RCAttributionFetcher.h, RCPurchases.m, and RCAttributionFetcher.m

Is it possible to remove this from the plugin so that we can successfully submit our app? Love the plugin and the RevenueCat approach, so really wouldn't want to remove our revenuecat integration and use another approach for subscriptions.

If there is a hack to do so please advise, any solution accepted right now!

Thanks,
Tom

Android crash

Hi,

I have migrated IAP to RevenueCat in my app. iOS works fine, but Android works only on 1st launch after deleting the app from test device. Looks like there's some bogus data in SharedPreferences. Any suggestions what I could try?

E/AndroidRuntime(30679): FATAL EXCEPTION: pool-8-thread-1
E/AndroidRuntime(30679): Process: net.poopmap, PID: 30679
E/AndroidRuntime(30679): java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Set
E/AndroidRuntime(30679): 	at android.app.SharedPreferencesImpl.getStringSet(SharedPreferencesImpl.java:293)
E/AndroidRuntime(30679): 	at com.revenuecat.purchases.DeviceCache.getPreviouslySentHashedTokens$purchases_release(DeviceCache.kt:100)
E/AndroidRuntime(30679): 	at com.revenuecat.purchases.DeviceCache.cleanPreviouslySentTokens(DeviceCache.kt:127)
E/AndroidRuntime(30679): 	at com.revenuecat.purchases.Purchases$updatePendingPurchaseQueue$1.run(Purchases.kt:926)
E/AndroidRuntime(30679): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(30679): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(30679): 	at java.lang.Thread.run(Thread.java:764)

Empty Offers Query

I'm having an issue with blank Offers coming back from the SDK. I'm on the flutter dev channel working in iOS:

Flutter 1.16.1 • channel dev • https://github.com/flutter/flutter.git
Framework • revision e6b0f5f238 (9 days ago) • 2020-03-18 21:56:02 -0400
Engine • revision 216c420a2c
Tools • Dart 2.8.0 (build 2.8.0-dev.15.0 96cf889e6b)

I noticed that the Pod for Purchases is at 3.2.1 and the flutter app is using the 3.0.x releases.

Expose `originalPurchaseDate` from `purchases-ios`

In reference to this purchases-ios PR, could originalPurchaseDate be exposed for flutter users please?

The currently exposed property originalApplicationVersion actually corresponds to the build number and not the version name. This is bad for migrating users since not all build numbers are unique for all versions. See the discussion in the PR linked above. All new developers of the project have to know this important optional constraint that is having distinct incremental build number regardless of version name.

This is impactful and wouldn't take much time to implement so I hope this gets you attention please.

getOffering returns null

Hi,

When I print out all the offerings I have, you can see the offerings particularly the one identified by the string "Default".

Offerings{current: Offering{identifier: Default, serverDescription: Subscription options., availablePackages: [Package{identifier: $rc_monthly, packageType: PackageType.monthly, product: Product{identifier: com.phntm.carbon.subscription, description: The subscription is required to access Carbon, title: Full Access, price: 11.989999771118164, priceString: $11.99, currencyCode: USD, introductoryPrice: null}, offeringIdentifier: Default}], lifetime: null, annual: null, sixMonth: null, threeMonth: null, twoMonth: null, monthly: Package{identifier: $rc_monthly, packageType: PackageType.monthly, product: Product{identifier: com.phntm.carbon.subscription, description: The subscription is required to access Carbon, title: Full Access, price: 11.989999771118164, priceString: $11.99, currencyCode: USD, introductoryPrice: null}, offeringIdentifier: Default}, weekly: null}, all: {Default: Offering{identifier: Default, serverDescription: Subscription options., availablePackages: [Package{identifie<…>

However, when I call the getOffering method on this, print(offerings.getOffering("Default"));

it prints out null and because of this when I try to get the Offering's package like this,
Package package = offerings.getOffering("Default").availablePackages[0];

it does not work, error Unhandled Exception: NoSuchMethodError: The getter 'availablePackages' was called on null.

Error when adding purchases-flutter as dependency

Hi Revenuecat team, first of all thankyou for creating this package. I'm able to run this packages in Flutter, but not without problem initially.

When i'm creating a new Flutter project, add purchases-flutter as dependencies and try to run it, i got this error:

e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\purchases_flutter-1.0.0\android\src\main\java\com\revenuecat\purchases\common\common.kt: (101, 37): Type mismatch: inferred type is String? but String was expected
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\purchases_flutter-1.0.0\android\src\main\java\com\revenuecat\purchases\common\common.kt: (168, 41): Type mismatch: inferred type is String? but String was expected
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\purchases_flutter-1.0.0\android\src\main\java\com\revenuecat\purchases\common\mappers.kt: (134, 31): Type mismatch: inferred type is String? but CharSequence was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':purchases_flutter:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s

Steps:

  1. flutter create project_name
  2. Add purchased_flutter: 1.0.0 to pubspec.yaml
  3. Run the project

After checking the example project and some trial and error, i found out that i need to change these files:

  • <project folder>/android/build.gradle: Change ext.kotlin_version to 1.3.60. Change gradle version to 3.5.2
  • <project folder/android/gradle/wrapper/gradle-wrapper.properties: Change distribution url to https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

My environments are as follow:

  • Flutter 1.9.1+hotfix.6
  • Dart 2.5.0
  • Windows 10

So i just want to ask what's the minimum requirement to use purchases-flutter? As the documentation doesn't mention it yet.

Create unified error enums or types

https://stackoverflow.com/questions/58410482/exposing-all-revenuecat-purchaseserrorcode-codes-in-flutter?sem=2

Expose error codes as enums or equivalent in Dart so they don't have to be hard-coded.

The proposed solution would be to add something like this

enum PurchasesErrorCode {
  UnknownError,
  PurchaseCancelledError,
  StoreProblemError,
  PurchaseNotAllowedError,
  PurchaseInvalidError,
  ProductNotAvailableForPurchaseError,
  ProductAlreadyPurchasedError,
  ReceiptAlreadyInUseError,
  InvalidReceiptError,
  MissingReceiptFileError,
  NetworkError,
  InvalidCredentialsError,
  UnexpectedBackendResponseError,
  ReceiptInUseByOtherSubscriberError,
  InvalidAppUserIdError,
  OperationAlreadyInProgressError,
  UnknownBackendError,
  InsufficientPermissionsError
}

try {
} on PlatformException catch (e) {
  PurchasesErrorCode errorCode = PurchasesErrorCode.values[int.parse(e.code)];
  switch (errorCode) {
    case PurchasesErrorCode.UnknownError:
    case PurchasesErrorCode.PurchaseCancelledError:
    case PurchasesErrorCode.StoreProblemError:
    // Add rest of cases
  }
}

Package support

Is the package going to be actively supported and evolving? I see that SDK for android and iOS get regularly updated, although there are no commits to flutter SDK for more than a month...

Purchase.reset() crash

If Purchase.reset() is called before Purchase.setup(...), i know it's bad but should not crash anyway:

*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff23c7127e __exceptionPreprocess + 350
        1   libobjc.A.dylib                     0x00007fff513fbb20 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff23c70ff8 +[NSException raise:format:arguments:] + 88
        3   Foundation                          0x00007fff256e9b51 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
        4   purchases_flutter                   0x000000010728d47d +[RCCommonFunctionality resetWithCompletionBlock:] + 333
        5   purchases_flutter                   0x000000010728b87b -[PurchasesFlutterPlugin resetWithResult:] + 123
        6   purchases_flutter                   0x000000010728a6c6 -[PurchasesFlutterPlugin handleMethodCall:result:] + 2454
        7   Flutter                             0x0000000104ecddb5 __45-[FlutterMethodChannel setMethodCa<…>

CocoaPods could not find compatible versions for pod "purchases_flutter":

I get this error running on iOS, it caused by this package, any Ideas?

CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    Finding Podfile changes
      A purchases_flutter
      - Flutter
      - audioplayers
      - cloud_firestore
      - firebase_analytics
      - firebase_auth
      - firebase_core
      - firebase_performance
      - flutter_keyboard_visibility
      - flutter_tts
      - google_sign_in
      - path_provider
      - shared_preferences
      - url_launcher
      - video_player
    Fetching external sources
    -> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
    -> Fetching podspec for `audioplayers` from `.symlinks/plugins/audioplayers/ios`
    -> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
    -> Fetching podspec for `firebase_analytics` from `.symlinks/plugins/firebase_analytics/ios`
    -> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    -> Fetching podspec for `firebase_performance` from `.symlinks/plugins/firebase_performance/ios`
    -> Fetching podspec for `flutter_keyboard_visibility` from `.symlinks/plugins/flutter_keyboard_visibility/ios`
    -> Fetching podspec for `flutter_tts` from `.symlinks/plugins/flutter_tts/ios`
    -> Fetching podspec for `google_sign_in` from `.symlinks/plugins/google_sign_in/ios`
    -> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
    -> Fetching podspec for `purchases_flutter` from `.symlinks/plugins/purchases_flutter/ios`
    -> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
    -> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`
    -> Fetching podspec for `video_player` from `.symlinks/plugins/video_player/ios`
    Resolving dependencies of `Podfile`
    [!] CocoaPods could not find compatible versions for pod "purchases_flutter":
      In Podfile:
        purchases_flutter (from `.symlinks/plugins/purchases_flutter/ios`)
    Specs satisfying the `purchases_flutter (from `.symlinks/plugins/purchases_flutter/ios`)` dependency were found, but they required a higher minimum deployment target.
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
    /Library/Ruby/Gems/2.3.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/resolver.rb:88:in `resolve'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer/analyzer.rb:939:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer/analyzer.rb:937:in `resolve_dependencies'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer/analyzer.rb:118:in `analyze'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer.rb:398:in `analyze'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer.rb:221:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer.rb:220:in `resolve_dependencies'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/installer.rb:156:in `install!'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/command/install.rb:51:in `run'
    /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.5/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:22:in `load'
    /usr/local/bin/pod:22:in `<main>'
Error output from CocoaPods:
↳
        WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
        Consider adding the following to ~/.profile:
        export LANG=en_US.UTF-8
        
    [!] Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error running pod install
Error launching application on iPhone 6.
Exited (sigterm)

I am getting empty offerings list on iOS

Currently, I am trying to setup RevenueCat on iOS and I have added

AppBundle ID, TunesConnect App-Specific Shared Secret, Didn't add p8 key as it's for iOS offers.

Also added Apple Server Notification URL to AppStore connect

But I am getting an empty offerings list in iOS.

How to unsubscribe ?

Hello, it's possible to use revenuecat futter sdk to call unsubscribe fonction to the store ? I don't see this function. New android rules force the develloper to be clear about informations, and show easy solution for the user to cancel subsription. thank you

iOS app crash on latest Flutter channel

On flutter beta and dev channel, using 1.0.4 version of purchases-flutter, when call method Purchases.getPurchaserInfo() iOS app crashes.

On Android it works.

This is the logs with flutter run:

 └─Compiling, linking and signing...                        12,6s
Xcode build done.                                           42,0s
Installing and launching...                                        26,3s
Lost connection to device.                                              
Syncing files to device iPhone di Matteo Ricupero...                    
                                                   
matteo@teobook fitet_unofficial_flutter % 

Actually no logs so I thought it was an issue with the Swift native code. If I run it from Xcode, it works.

Handle Slow card purchases

I'm using a "Slow card" option to test a purchase. Is there a way to get a purchase status when it finishes (in order to show success/error message or direct user to unlocked page, etc)?

I do receive a callback in PurchaserInfoUpdateListener after transaction finished, but I'm not able to say if purchase succeeded or not.

iOS Sandbox Subscription Renewal

This is a duplicate issue of #50 but no one responded.

Flutter 1.17.3 stable
Dart 2.8.4
purchases_flutter 1.1.1

Plan: build

When purchasing a subscription via sandbox, it'll renew 5 times and then auto cancel.

At this point, I'd like to renew the subscription and it fails here. I've tried using both purchase methods purchasePackage and purchaseProduct with no success.

I'd also like to mention that if I close the app and reopen it and try to renew every so often it'll work, but 90% of the time it won't.

Support for stripe subscriptions

For real world goods and services it's possible to use stripe subscriptions instead of apple's IAP subscriptions. Given that Stripe subscriptions are in beta on RevenueCat it would be great if this package would support fetching/purchasing using Stripe in place of the native platform subscription

Offline Support for Entitlements

Our app can be used offline and user has a certain quota on how many records he can create.

So we need a way to fetch Entitlement info offline as well (the one fetched recently) so that we can tally user's quota with what entitlement is available to them.

Is there any way to do this already?

Purchases.getEntitlements() results in PlatformException: Text cannot be parsed to a Period

Since upgrading to 0.3.0, when I call Purchases.getEntitlements() I get this PlatformException:

I/flutter ( 3369): PlatformException(error, Text cannot be parsed to a Period: , null) 
I/flutter ( 3369): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
I/flutter ( 3369): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
I/flutter ( 3369): <asynchronous suspension>
I/flutter ( 3369): #2      Purchases.getEntitlements (package:purchases_flutter/purchases_flutter.dart:96:24)
I/flutter ( 3369): <asynchronous suspension>

D/[Purchases] - DEBUG( 3369): Vending entitlements from cache
E/MethodChannel#purchases_flutter( 3369): Failed to handle method call
E/MethodChannel#purchases_flutter( 3369): java.lang.RuntimeException: Text cannot be parsed to a Period: 
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.PurchasesPeriod.parse(PurchasesPeriod.java:92)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.Mappers.putIntroPrice(Mappers.java:74)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.Mappers.map(Mappers.java:34)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.Mappers.map(Mappers.java:146)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.PurchasesFlutterPlugin.mapEntitlementsAndCacheProducts(PurchasesFlutterPlugin.java:188)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.PurchasesFlutterPlugin.access$100(PurchasesFlutterPlugin.java:41)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.PurchasesFlutterPlugin$3.onReceived(PurchasesFlutterPlugin.java:177)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases.Purchases$getEntitlements$$inlined$let$lambda$1.invoke(Purchases.kt:217)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases.Purchases$getEntitlements$$inlined$let$lambda$1.invoke(Purchases.kt:50)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases.Purchases.dispatch(Purchases.kt:779)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases.Purchases.getEntitlements(Purchases.kt:216)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.PurchasesFlutterPlugin.getEntitlements(PurchasesFlutterPlugin.java:174)
E/MethodChannel#purchases_flutter( 3369): 	at com.revenuecat.purchases_flutter.PurchasesFlutterPlugin.onMethodCall(PurchasesFlutterPlugin.java:93)
E/MethodChannel#purchases_flutter( 3369): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#purchases_flutter( 3369): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#purchases_flutter( 3369): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#purchases_flutter( 3369): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#purchases_flutter( 3369): 	at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#purchases_flutter( 3369): 	at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#purchases_flutter( 3369): 	at android.app.ActivityThread.main(ActivityThread.java:6541)
E/MethodChannel#purchases_flutter( 3369): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#purchases_flutter( 3369): 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/MethodChannel#purchases_flutter( 3369): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

flutter doctor -v

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-SE)
    • Flutter version 1.7.8+hotfix.4 at /Users/Magnus/development/flutter
    • Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/Magnus/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.6.1

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 33.3.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 33.3.2
    • Dart plugin version 183.5901

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)

• No issues found!

There was a problem with the Play Store.

I have error when try restore or make purchase that is
The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.

I have linked google play console and my offers and products show up correctly no problems and dialog payment open in android but when payment accepted this issue show up.

There was a problem with the Play Store. | Google Play Error: The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.
E/[Purchases] - ERROR(25803): Error restoring purchase: PurchaseHistoryRecordWrapper(isConsumable=false, purchaseToken=dejlibmkgfkdmbfpkjcbpjad.AO-J1OxzpOIopGM40HPA24XehEpMBo2NrH6ECqknMhTb0O81K3H5nbuQdvmZruwW4D_1rRPOw_k8yuISaJ012a5Rt1fypI4I5GG1gvkuh8XwuRXRH1zpZWwR5F8V3Y_3Yu_OPfhQWUn1, purchaseTime=1590674046109, sku=monthly_subscription, purchaseHistoryRecord=PurchaseHistoryRecord. Json: {"productId":"monthly_subscription","purchaseToken":"dejlibmkgfkdmbfpkjcbpjad.AO-J1OxzpOIopGM40HPA24XehEpMBo2NrH6ECqknMhTb0O81K3H5nbuQdvmZruwW4D_1rRPOw_k8yuISaJ012a5Rt1fypI4I5GG1gvkuh8XwuRXRH1zpZWwR5F8V3Y_3Yu_OPfhQWUn1","purchaseTime":1590674046109,"developerPayload":null}, type=SUBS); Error: PurchasesError(code=StoreProblemError, underlyingErrorMessage=Google Play Error: The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console., message='There was a problem with the Play Store.')
I/flutter (25803): Error caught by Crashlytics plugin <recordError>:
I/flutter (25803): PlatformException(2, There was a problem with the Play Store., {code: 2, message: There was a problem with the Play Store., readableErrorCode: StoreProblemError, readable_error_code: StoreProblemError, underlyingErrorMessage: Google Play Error: The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.})

Errors running Pod Install

Every time I add this package to a Flutter project and then try to run it, I get a Pod error. I've tried going back to a completely new Flutter app and running it and it still errors.

Here is the error message:

Error output from CocoaPods:

[!] Automatically assigning platform `iOS` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install
Error launching application on iPhone 11 Pro.

MacOS Support

I thought MacOS was supported? Can you show me documentation to get started? Works great on iOS and Android. Also is web support for Flutter web added?

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method setDebugLogsEnabled on channel purchases_flutter)
#0      MethodChannel._invokeMethod 
package:flutter/…/services/platform_channel.dart:154
<asynchronous suspension>
#1      MethodChannel.invokeMethod 
package:flutter/…/services/platform_channel.dart:329
#2      Purchases.setDebugLogsEnabled 
package:purchases_flutter/purchases_flutter.dart:243
#3      CartBloc.mapEventToState 
package:hymns_for_worship/…/cart/cart_bloc.dart:45
<asynchronous suspension>
#4      Bloc._bindStateSubject.<anonymous closure> 
package:bloc/src/bloc.dart:155
#5      Stream.asyncExpand.onListen.<anonymous closure>  (dart:async/stream.dart:576:30)
#6      _rootRunUnary  (dart:async/zone.dart:1134:38)
#7      _CustomZone.runUnary  (dart:async/zone.dart:1031:19)
#8      _CustomZone.runUnaryGuarded  (dart:async/zone.dart:933:7)
#9      _BufferingStreamSubscription._sendData  (dart:async/stream_impl.dart:339:11)
#10     _DelayedData.perform  (dart:async/stream_impl.dart:594:14)
#11     _StreamImplEvents.handleNext  (dart:async/stream_impl.dart:710:11)
#12     _PendingEvents.schedule.<anonymous closure>  (dart:async/stream_impl.dart:670:7)
#13     _rootRun  (dart:async/zone.dart:1122:38)
#14     _CustomZone.run  (dart:async/zone.dart:1023:19)
#15     _CustomZone.runGuarded  (dart:async/zone.dart:925:7)
#16     _CustomZone.bindCallbackGuarded.<anonymous closure>  (dart:async/zone.dart:965:23)
#17     _rootRun  (dart:async/zone.dart:1126:13)
#18     _CustomZone.run  (dart:async/zone.dart:1023:19)
#19     _CustomZone.runGuarded  (dart:async/zone.dart:925:7)
#20     _CustomZone.bindCallbackGuarded.<anonymous closure>  (dart:async/zone.dart:965:23)
#21     _microtaskLoop  (dart:async/schedule_microtask.dart:43:21)
#22     _startMicrotaskLoop  (dart:async/schedule_microtask.dart:52:5)

How to set auto-renewable subscription?

Perhaps. this question is so dumb, but I really want to know how can I use auto-renewable subscription, I saw your article in the site about restoring, but I couldn't understand how to implement it.

TestFlight users resubscribe every restart

For some reason if you use the subscription action in an app installed through TestFlight it resets the test subscription every time you force close the app. Subscriptions work though the App Store though.

[Android] The product is not available for purchase

No products show up when running on android, no issues with iOS. Looks like Purchases.getProducts(_kProductIds) is returning an empty list.

Debug log:

D/[Purchases] - DEBUG( 6769): Debug logging enabled.
D/[Purchases] - DEBUG( 6769): SDK Version - 3.1.0
D/[Purchases] - DEBUG( 6769): Initial App User ID - null
D/[Purchases] - DEBUG( 6769): Identifying App User ID: $RCAnonymousID:658fdef78ace4f2794fe6cdcfe129f86
D/[Purchases] - DEBUG( 6769): App foregrounded
D/[Purchases] - DEBUG( 6769): PurchaserInfo cache is stale, updating caches
D/[Purchases] - DEBUG( 6769): Offerings cache is stale, updating caches
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Skipping updating pending purchase queue since BillingClient is not connected yet
D/[Purchases] - DEBUG( 6769): No subscriber attributes to synchronize.
D/[Purchases] - DEBUG( 6769): Subscriber attributes synced successfully.
D/[Purchases] - DEBUG( 6769): Listener set
D/[Purchases] - DEBUG( 6769): Sending latest purchaser info to listener
D/[Purchases] - DEBUG( 6769): Starting connection for com.android.billingclient.api.BillingClientImpl@9a35617
D/[Purchases] - DEBUG( 6769): Billing Service Setup finished for com.android.billingclient.api.BillingClientImpl@9a35617.
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Updating pending purchase queue
D/[Purchases] - DEBUG( 6769): Vending purchaserInfo from cache
D/[Purchases] - DEBUG( 6769): Requesting products with identifiers: tieronetip, tier3tip, tier5tip, tier10tip, tier21tip
D/[Purchases] - DEBUG( 6769): Products request finished for tieronetip, tier3tip, tier5tip, tier10tip, tier21tip
D/[Purchases] - DEBUG( 6769): Retrieved skuDetailsList: 
D/[Purchases] - DEBUG( 6769): Attribution data is the same as latest. Skipping.
D/[Purchases] - DEBUG( 6769): GET /subscribers/%24RCAnonymousID%3A658fdef78ace4f2794fe6cdcfe129f86
D/[Purchases] - DEBUG( 6769): GET /subscribers/%24RCAnonymousID%3A658fdef78ace4f2794fe6cdcfe129f86 200
D/[Purchases] - DEBUG( 6769): Purchaser info updated, sending to listener
D/[Purchases] - DEBUG( 6769): GET /subscribers/%24RCAnonymousID%3A658fdef78ace4f2794fe6cdcfe129f86/offerings
D/[Purchases] - DEBUG( 6769): GET /subscribers/%24RCAnonymousID%3A658fdef78ace4f2794fe6cdcfe129f86/offerings 200
D/[Purchases] - DEBUG( 6769): Requesting products with identifiers: 
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Querying subs
D/[Purchases] - DEBUG( 6769): Products request finished for 
D/[Purchases] - DEBUG( 6769): Retrieved skuDetailsList: 
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Querying inapp
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Cleaning previously sent tokens
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Tokens already posted: []
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Saving tokens []
D/[Purchases] - DEBUG( 6769): [QueryPurchases] Tokens already posted: []
W/FA      ( 6769): setCurrentScreen cannot be called with the same class and name
I/FIAM.Headless( 6769): Removing display event listener
D/[Purchases] - DEBUG( 6769): App backgrounded
D/[Purchases] - DEBUG( 6769): No subscriber attributes to synchronize.
D/[Purchases] - DEBUG( 6769): Subscriber attributes synced successfully.
W/ic.theunwanted( 6769): Accessing hidden method Ldalvik/system/CloseGuard;->close()V (greylist,core-platform-api, linking, allowed)

IOS 13.4 Update After - Flutter

Hello Dear.

Payment does not start after updating.
Sometimes it starts but not as a sandbox user. process is canceled when i enter my password
The mistake I usually get is this PurchasesErrorCode.storeProblemError.
All of this happened after upgrading to 13.4.

Slow test card: RangeError (index): Invalid value: Not in range 0..18, inclusive: 20

Hi, I'm testing purchases with "Slow test card" on Android and right after payment window is closed the Exception is thrown "RangeError (index): Invalid value: Not in range 0..18, inclusive: 20"

Code:

try {
    final purchaserInfo = await Purchases.purchasePackage(package);
} on PlatformException catch (e) {
    var errorCode = PurchasesErrorHelper.getErrorCode(e); //<--- error here
    if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
        print(e);
    }
}

It seems that code for the "The payment is pending." exception is 20.

After data change getPurchaserInfo returns cached data first and only then downloads update

If some purchaser data changes in background (f.e. subscription expires) and the app is trying to get purchaser info
final purchaserInfo = await Purchases.getPurchaserInfo();
purchaserInfo still contains old data.

I can see from the logs that change was detected:
D/[Purchases] - DEBUG(29537): Vending purchaserInfo from cache
D/[Purchases] - DEBUG(29537): Cache is stale, updating caches
D/[Purchases] - DEBUG(29537): Purchaser info updated, sending to listener

But description of the method implies that it should return newest state (at least this is how I understand it):

Gets current purchaser info, which will normally be cached.

Wouldn't it be better if getPurchaserInfo awaited for new data whenever there was a change and returned from cache when there wasn't?

PurchaserInfo missing properties

The documentation mentions that the PurchaserInfo has two properties called Request Date and Original Application Version, but they don't seem to be present in the Flutter version of PurchaserInfo?

The documentation even specifically says that you should user Request Date rather than device time to make time comparisons.

property 'identifier' not found on object of type 'SKProductDiscount *'

I get this error when running on an iOS Simulator

Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'in_app_purchase')
    warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'in_app_purchase')
    warning: Capabilities for Runner may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the build settings editor. (in target 'Runner')
    /Users/jonas/Projects/ProjectFit/mobile/training_hub_flutter/ios/Pods/Purchases/Purchases/RCPromotionalOffer.m:21:48: error: property 'identifier' not found on object of type 'SKProductDiscount *'
            self.offerIdentifier = productDiscount.identifier;
                                                   ^
    1 error generated.
    note: Using new build systemnote: Planning buildnote: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 8.

Error restoring purchase on Android: getPurchaseHistory() failed. Response code: 6

D/[Purchases] - DEBUG( 1601): Restoring purchases
D/[Purchases] - DEBUG( 1601): Querying purchase history for type subs
W/BillingClient( 1601): getPurchaseHistory() failed. Response code: 6
W/[Purchases] - INFO( 1601): Error receiving purchase history. DebugMessage: An internal error occurred.. ErrorCode: ERROR.
E/[Purchases] - ERROR( 1601): There was a problem with the Play Store. | Error receiving purchase history. DebugMessage: An internal error occurred.. ErrorCode: ERROR.
I/flutter ( 1601): 💡  DebugTestingScreen - error: PlatformException(2, There was a problem with the Play Store., {code: 2, message: There was a problem with the Play Store., readableErrorCode: StoreProblemError, readable_error_code: StoreProblemError, underlyingErrorMessage: Error receiving purchase history. DebugMessage: An internal error occurred.. ErrorCode: ERROR.})

Fatal Exception: java.lang.RuntimeException: Text cannot be parsed to a Period: 365

We got some crash reports with the following stack trace on Android devices:

Fatal Exception: java.lang.RuntimeException: Text cannot be parsed to a Period: 365
       at com.revenuecat.purchases.common.PurchasesPeriod.parse(PurchasesPeriod.java:125)
       at com.revenuecat.purchases.common.MappersKt.mapPeriod(MappersKt.java:17)
       at com.revenuecat.purchases.common.MappersKt.mapIntroPrice(MappersKt.java:102)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:98)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:37)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:63)
       at com.revenuecat.purchases.common.MappersKt.map(MappersKt.java:63)
       at com.revenuecat.purchases.common.CommonKt$getOfferings$2.invoke(CommonKt.java:7)
       at com.revenuecat.purchases.common.CommonKt$getOfferings$2.invoke(CommonKt.java:2)
       at com.revenuecat.purchases.ListenerConversionsKt$receiveOfferingsListener$1.onReceived(ListenerConversionsKt.java:7)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1$2.invoke(Purchases.java:10)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1$2.invoke(Purchases.java)
       at com.revenuecat.purchases.Purchases.dispatch(Purchases.java:60)
       at com.revenuecat.purchases.Purchases.access$dispatch(Purchases.java)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1.invoke(Purchases.java:46)
       at com.revenuecat.purchases.Purchases$fetchAndCacheOfferings$1$1.invoke(Purchases.java:2)
       at com.revenuecat.purchases.Purchases$getSkuDetails$1$1.invoke(Purchases.java:55)
       at com.revenuecat.purchases.Purchases$getSkuDetails$1$1.invoke(Purchases.java:2)
       at com.revenuecat.purchases.BillingWrapper$querySkuDetailsAsync$1$1.onSkuDetailsResponse(BillingWrapper.java:159)
       at com.android.billingclient.api.BillingClientImpl$10$1.run(BillingClientImpl.java:36)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7073)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

No way to access Package description?

A description can be set for a Package in the RevenueCat dashboard, but I can't find any way to access it using version 1.1.0 of the Flutter plugin?

Failed to compile on android

Hi Revenuecat team, first of all thank you this package. I'm able to run this packages in Flutter.

I was using the package revenuecat, and now I decided to start using the official library, but I'm having troubles to execute my app when I add to my dependencies

purchases_flutter: ^1.0.4

I'm giving the following error:

`
e: /Users/macbook/development/flutter/.pub-cache/hosted/pub.dartlang.org/purchases_flutter-1.0.4/android/src/main/java/com/revenuecat/purchases/common/mappers.kt: (109, 60): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
@InlineOnly public inline operator fun BigDecimal.div(other: BigDecimal): BigDecimal defined in kotlin
@InlineOnly public inline operator fun BigInteger.div(other: BigInteger): BigInteger defined in kotlin

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':purchases_flutter:compileDebugKotlin'.

Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s
`
Info:

My Kotlin version ext.kotlin_version = '1.3.60'

Flutter Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.2 19C57, locale
es-EC)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[!] Android Studio (version 3.5)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.43.0)
[✓] Connected device (1 available)

! Doctor found issues in 1 category

not succeded to work with example

Hello I tried to test your example, I have configure all revenuecat, playstore subscribing is active, I replace my setup "id" of the example lib, use my entitlements key "pro". After launch app I switch in the Upsell Screen and raisedbutton to lanch purchase. but when I press i have:


Another exception was thrown: Instance of 'DiagnosticsProperty<void>'
E/flutter (20491): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'identifier' was called on null.
E/flutter (20491): Receiver: null
E/flutter (20491): Tried calling: identifier
E/flutter (20491): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53)
E/flutter (20491): #1      Purchases.purchasePackage (package:purchases_flutter/purchases_flutter.dart:177)
E/flutter (20491): #2      UpsellScreen.build.<anonymous closure> (package:ouiquit_app/revenuecat.dart:121)
E/flutter (20491): #3      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706)
E/flutter (20491): #4      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789)
E/flutter (20491): #5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182)
E/flutter (20491): #6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486)
E/flutter (20491): #7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:281)
E/flutter (20491): #8      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236)
E/flutter (20491): #9      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156)
E/flutter (20491): #10     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222)
E/flutter (20491): #11     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198)
E/flutter (20491): #12     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156)
E/flutter (20491): #13     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102)
E/flutter (20491): #14     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86)
E/flutter (20491): #15     _rootRunUnary (dart:async/zone.dart:1138)
E/flutter (20491): #16     _CustomZone.runUnary (dart:async/zone.dart:1031)
E/flutter (20491): #17     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
E/flutter (20491): #18     _invoke1 (dart:ui/hooks.dart:273)
E/flutter (20491): #19     _dispatchPointerDataPacket (dart:ui/hooks.dart:182)
E/flutter (20491): 

When I tri to listen the state of offering I have : Offerings{current:null,all:{}}

here is my example :


class InitialScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _MyAppState();
}

class _MyAppState extends State<InitialScreen> {
  PurchaserInfo _purchaserInfo;
  Offerings _offerings;

  String identifiant;
  Future<void> id() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();

    identifiant= prefs.getString("code_unique");
  }


  @override
  void initState() {
    super.initState();
    id();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    await Purchases.setDebugLogsEnabled(true);
    await Purchases.setup("My_revenuecat_id", appUserId: "$identifiant");

    Purchases.addAttributionData({}, PurchasesAttributionNetwork.facebook);
    PurchaserInfo purchaserInfo = await Purchases.getPurchaserInfo();
    Offerings offerings = await Purchases.getOfferings();
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _purchaserInfo = purchaserInfo;
      _offerings = offerings;
    });
  }

  @override
  Widget build(BuildContext context) {
    if (_purchaserInfo == null) {
      return Scaffold(
        appBar: AppBar(title: Text("RevenueCat Sample App")),
        body: Center(
          child: Text("Loading"),
        ),
      );
    } else {
      var isPro = _purchaserInfo.entitlements.active.containsKey("pro");
      if (isPro) {
        return CatsScreen();
      } else {
        return UpsellScreen(
          offerings: _offerings,
        );
      }
    }
  }
}



class UpsellScreen extends StatelessWidget {
  final Offerings offerings;

  UpsellScreen({Key key, @required this.offerings}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    if (offerings != null) {
      final offering = offerings.current;
      if (offering != null) {
        final monthly = offering.monthly;
        if (monthly != null ) {
          return Scaffold(
              appBar: AppBar(title: Text("Upsell Screen1")),
              body: Center(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      PurchaseButton(package: monthly),
                    ],
                  )));
        }
      }
    }

    return Scaffold(
        appBar: AppBar(title: Text("Upsell Screen2")),
        body: Center(
          child: Text("Loading... "),
        ));
  }
}

class PurchaseButton extends StatelessWidget {
  final Package package;

  PurchaseButton({Key key, @required this.package}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return RaisedButton(
      onPressed: () async {
        try {
          PurchaserInfo purchaserInfo =
          await Purchases.purchasePackage(package);
          var isPro = purchaserInfo.entitlements.all["pro"].isActive;
          if (isPro) {
            return CatsScreen();
          }
        } on PlatformException catch (e) {
          var errorCode = PurchasesErrorHelper.getErrorCode(e);
          if (errorCode == PurchasesErrorCode.purchaseCancelledError) {
            print("User cancelled");
          } else if (errorCode == PurchasesErrorCode.purchaseNotAllowedError) {
            print("User not allowed to purchase");
          }
        }
        return InitialScreen();
      },
      child: Text("Buy - (${package.product.priceString})"),
    );
  }
}

class CatsScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text("Cats Screen")),
        body: Center(
          child: Text("User is pro"),
        ));
  }
}

unable to spawn process (Argument list too long) Xcode archive error

Ran custom shell script'[CP] Check Pods Manifest.lock

PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/elias/Library/Developer/Xcode/DerivedData/Runner-fiuohnrdzlkuxddgjocwyhssndsw/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-4AE03761ECB993EA059947D1.sh (in target 'Runner' from project 'Runner')
    cd /Users/elias/Documents/GitHub/isontic-Education/Education-Mobile/ios
    /bin/sh -c /Users/elias/Library/Developer/Xcode/DerivedData/Runner-fiuohnrdzlkuxddgjocwyhssndsw/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-4AE03761ECB993EA059947D1.sh
error: unable to spawn process (Argument list too long) (in target 'Runner' from project 'Runner')

flutter doctor -v

[✓] Flutter (Channel dev, v1.13.7, on Mac OS X 10.15.2 19C57, locale en-US)
    • Flutter version 1.13.7 at /Users/elias/flutter
    • Framework revision a3bbdfb23a (5 days ago), 2020-01-03 16:19:11 -0500
    • Engine revision eb139936eb
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 2f57602411)

 
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/elias/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3, Build version 11C29
    • CocoaPods version 1.7.5

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (3 available)
    • macOS      • macOS      • darwin-x64     • Mac OS X 10.15.2 19C57
    • Chrome     • chrome     • web-javascript • Google Chrome 79.0.3945.88
    • Web Server • web-server • web-javascript • Flutter Tools

! Doctor found issues in 1 category.
elias@isontic-MBP-01 Education-Mobile % 

Screen Shot 2020-01-08 at 11 46 39 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.