-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove embedding v1 support #1141
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
|
||
import com.revenuecat.purchases.DangerousSettings; | ||
import com.revenuecat.purchases.Purchases; | ||
import com.revenuecat.purchases.PurchasesAreCompletedBy; | ||
import com.revenuecat.purchases.PurchasesErrorCode; | ||
import com.revenuecat.purchases.Store; | ||
import com.revenuecat.purchases.common.PlatformInfo; | ||
|
@@ -51,11 +50,6 @@ public class PurchasesFlutterPlugin implements FlutterPlugin, MethodCallHandler, | |
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated"; | ||
protected static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent"; | ||
|
||
// Only set registrar for v1 embedder. | ||
@SuppressWarnings("deprecation") | ||
private io.flutter.plugin.common.PluginRegistry.Registrar registrar; | ||
// Only set activity for v2 embedder. Always access activity from getActivity() | ||
// method. | ||
@Nullable | ||
private Context applicationContext; | ||
@Nullable | ||
|
@@ -68,27 +62,6 @@ public class PurchasesFlutterPlugin implements FlutterPlugin, MethodCallHandler, | |
private static final String PLATFORM_NAME = "flutter"; | ||
private static final String PLUGIN_VERSION = "7.0.2"; | ||
|
||
/** | ||
* Plugin registration. | ||
*/ | ||
@SuppressWarnings("deprecation") | ||
public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) { | ||
PurchasesFlutterPlugin instance = new PurchasesFlutterPlugin(); | ||
instance.onAttachedToEngine(registrar.messenger(), registrar.context()); | ||
instance.registrar = registrar; | ||
registrar.addViewDestroyListener(new io.flutter.plugin.common.PluginRegistry.ViewDestroyListener() { | ||
@Override | ||
public boolean onViewDestroy(io.flutter.view.FlutterNativeView flutterNativeView) { | ||
try { | ||
Purchases.getSharedInstance().close(); | ||
} catch (UninitializedPropertyAccessException e) { | ||
// there's no instance so all good | ||
} | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { | ||
onAttachedToEngine(binding.getBinaryMessenger(), binding.getApplicationContext()); | ||
|
@@ -129,10 +102,6 @@ public void onDetachedFromActivityForConfigChanges() { | |
onDetachedFromActivity(); | ||
} | ||
|
||
public Activity getActivity() { | ||
return registrar != null ? registrar.activity() : activity; | ||
} | ||
|
||
@Override | ||
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | ||
switch (call.method) { | ||
|
@@ -219,7 +188,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | |
setDebugLogsEnabled(enabled, result); | ||
break; | ||
case "setLogLevel": | ||
String level = (String) call.argument("level"); | ||
String level = call.argument("level"); | ||
setLogLevel(level, result); | ||
break; | ||
case "setProxyURLString": | ||
|
@@ -232,10 +201,6 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | |
case "syncPurchases": | ||
syncPurchases(result); | ||
break; | ||
case "enableAdServicesAttributionTokenCollection": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Took the chance to cleanup a few warnings I was getting in Android studio. |
||
// NOOP | ||
result.success(null); | ||
break; | ||
case "isAnonymous": | ||
isAnonymous(result); | ||
break; | ||
|
@@ -256,6 +221,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | |
case "beginRefundRequestForProduct": | ||
case "beginRefundRequestForEntitlement": | ||
case "recordPurchaseForProductID": | ||
case "enableAdServicesAttributionTokenCollection": | ||
// NOOP | ||
result.success(null); | ||
break; | ||
|
@@ -457,7 +423,7 @@ private void purchaseProduct(final String productIdentifier, | |
@Nullable final Map<String, Object> presentedOfferingContext, | ||
final Result result) { | ||
CommonKt.purchaseProduct( | ||
getActivity(), | ||
activity, | ||
productIdentifier, | ||
type, | ||
null, | ||
|
@@ -475,7 +441,7 @@ private void purchasePackage(final String packageIdentifier, | |
@Nullable final Boolean googleIsPersonalizedPrice, | ||
final Result result) { | ||
CommonKt.purchasePackage( | ||
getActivity(), | ||
activity, | ||
packageIdentifier, | ||
presentedOfferingContext, | ||
googleOldProductId, | ||
|
@@ -492,7 +458,7 @@ private void purchaseSubscriptionOption(final String productIdentifier, | |
@Nullable final Map<String, Object> presentedOfferingContext, | ||
final Result result) { | ||
CommonKt.purchaseSubscriptionOption( | ||
getActivity(), | ||
activity, | ||
productIdentifier, | ||
optionIdentifier, | ||
googleOldProductId, | ||
|
@@ -744,12 +710,12 @@ private void runOnUiThread(Runnable runnable) { | |
private OnResult getOnResult(final Result result) { | ||
return new OnResult() { | ||
@Override | ||
public void onReceived(Map<String, ?> map) { | ||
public void onReceived(@NotNull Map<String, ?> map) { | ||
result.success(map); | ||
} | ||
|
||
@Override | ||
public void onError(ErrorContainer errorContainer) { | ||
public void onError(@NotNull ErrorContainer errorContainer) { | ||
reject(errorContainer, result); | ||
} | ||
}; | ||
|
@@ -764,7 +730,7 @@ public void onReceived(@Nullable Map<String, ?> map) { | |
} | ||
|
||
@Override | ||
public void onError(ErrorContainer errorContainer) { | ||
public void onError(@NotNull ErrorContainer errorContainer) { | ||
reject(errorContainer, result); | ||
} | ||
}; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to clean this up 👍