-
Notifications
You must be signed in to change notification settings - Fork 20
Add basic interface for Customer Center #712
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
cd94337
Add basic interface for customer center
facumenzella e9739bc
Merge branch 'main' into feat/customercenter-staticinterface
facumenzella 6f3b3d8
Merge remote-tracking branch 'origin/main' into feat/customercenter-s…
facumenzella 4cb892d
Merge branch 'feat/customercenter-staticinterface' of github.com:Reve…
facumenzella 48a35fe
update deps
facumenzella 3b54e0b
Merge branch 'main' into feat/customercenter-staticinterface
facumenzella 6c90d5b
Add empty CustomerCenterCallbacks
facumenzella d846da5
Merge branch 'feat/customercenter-staticinterface' of github.com:Reve…
facumenzella 8ad87e1
Remove result
facumenzella 388aa64
remove extras
facumenzella 9c01e8d
push missing piece
facumenzella 15bc076
callbacks
vegaro 893a33f
add callbacks to PurchasesListener
vegaro 6574a3a
fix missing callback
vegaro f9e3a4b
remove catching to prevent catching devs exceptions
vegaro 71a8b60
log clean up
vegaro a18dc9b
add internal back
vegaro 01a351e
assign instead of copy
facumenzella e88bb72
fix indentation
vegaro 5c97e94
NormalizeNullString
vegaro 65f5025
private constructor
vegaro b14e0e5
fix );
vegaro 9be5133
made events internal
vegaro 6309e18
log cleanup
vegaro 8a79fbd
fix whitespace
vegaro c530fc3
Revert "fix whitespace"
vegaro 7695ad2
fix whitespace
vegaro 49261da
replace with constants instead of enum
vegaro 9911fdf
make CallbacksProxy internal to fix compilation
vegaro 3c4795d
Merge branch 'main' into feat/customercenter-staticinterface
vegaro 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
144 changes: 144 additions & 0 deletions
144
...dlib/src/main/java/com/revenuecat/purchasesunity/ui/CustomerCenterTrampolineActivity.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| package com.revenuecat.purchasesunity.ui; | ||
|
|
||
| import android.app.Activity; | ||
| import android.content.Intent; | ||
| import android.os.Bundle; | ||
| import android.util.Log; | ||
|
|
||
| import androidx.activity.ComponentActivity; | ||
| import androidx.activity.result.ActivityResultLauncher; | ||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
|
|
||
| import com.revenuecat.purchases.Purchases; | ||
| import com.revenuecat.purchases.customercenter.CustomerCenterListener; | ||
| import com.revenuecat.purchases.hybridcommon.mappers.MappersHelpersKt; | ||
| import com.revenuecat.purchases.hybridcommon.ui.CustomerCenterListenerWrapper; | ||
| import com.revenuecat.purchases.ui.revenuecatui.customercenter.ShowCustomerCenter; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import kotlin.Unit; | ||
|
|
||
| public class CustomerCenterTrampolineActivity extends ComponentActivity { | ||
| private static final String TAG = "PurchasesUnity"; | ||
|
|
||
| private ActivityResultLauncher<Unit> launcher; | ||
| private CustomerCenterListener customerCenterListener; | ||
|
|
||
| @Override | ||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
|
|
||
| launcher = registerForActivityResult( | ||
| new ShowCustomerCenter(), | ||
| ignored -> { | ||
| RevenueCatUI.sendCustomerCenterDismissed(); | ||
| finish(); | ||
| } | ||
| ); | ||
|
|
||
| if (!Purchases.isConfigured()) { | ||
| Log.e(TAG, "Purchases is not configured. Cannot launch Customer Center."); | ||
| RevenueCatUI.sendCustomerCenterError(); | ||
| finish(); | ||
| return; | ||
| } | ||
|
|
||
| customerCenterListener = createCustomerCenterListener(); | ||
| Purchases.getSharedInstance().setCustomerCenterListener(customerCenterListener); | ||
|
|
||
| try { | ||
| launcher.launch(Unit.INSTANCE); | ||
| } catch (Throwable t) { | ||
| Log.e(TAG, "Error launching CustomerCenterActivity", t); | ||
| RevenueCatUI.sendCustomerCenterError(); | ||
| finish(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void onDestroy() { | ||
| super.onDestroy(); | ||
| if (Purchases.isConfigured()) { | ||
| Purchases.getSharedInstance().setCustomerCenterListener(null); | ||
| } | ||
| } | ||
|
|
||
| private CustomerCenterListener createCustomerCenterListener() { | ||
| return new CustomerCenterListenerWrapper() { | ||
| @Override | ||
| public void onManagementOptionSelectedWrapper(@NonNull String s, | ||
| @Nullable String s1, | ||
| @Nullable String s2) { | ||
| // Ignored since it's deprecated | ||
| } | ||
|
|
||
| @Override | ||
| public void onFeedbackSurveyCompletedWrapper(@Nullable String feedbackSurveyOptionId) { | ||
| if (feedbackSurveyOptionId != null) { | ||
| RevenueCatUI.sendFeedbackSurveyCompleted(feedbackSurveyOptionId); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onManagementOptionSelectedWrapper(@Nullable String action, | ||
| @Nullable String url) { | ||
| if (action != null) { | ||
| RevenueCatUI.sendManagementOptionSelected(action, url); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onCustomActionSelectedWrapper(@Nullable String actionId, | ||
| @Nullable String purchaseIdentifier) { | ||
| if (actionId != null) { | ||
| RevenueCatUI.sendCustomActionSelected(actionId, purchaseIdentifier); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onShowingManageSubscriptionsWrapper() { | ||
| RevenueCatUI.sendShowingManageSubscriptions(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onRestoreCompletedWrapper(@Nullable Map<String, ?> customerInfo) { | ||
| if (customerInfo != null) { | ||
| String customerInfoJson = MappersHelpersKt.convertToJson(customerInfo).toString(); | ||
| RevenueCatUI.sendRestoreCompleted(customerInfoJson); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onRestoreFailedWrapper(@Nullable Map<String, ?> error) { | ||
| if (error != null) { | ||
| String errorJson = MappersHelpersKt.convertToJson(error).toString(); | ||
| RevenueCatUI.sendRestoreFailed(errorJson); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onRestoreStartedWrapper() { | ||
| RevenueCatUI.sendRestoreStarted(); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public static void presentCustomerCenter(Activity activity) { | ||
| if (activity == null) { | ||
| Log.e(TAG, "Activity is null; cannot launch Customer Center"); | ||
| RevenueCatUI.sendCustomerCenterError(); | ||
| return; | ||
| } | ||
|
|
||
| Intent intent = new Intent(activity, CustomerCenterTrampolineActivity.class); | ||
|
|
||
| try { | ||
| activity.startActivity(intent); | ||
| } catch (Throwable t) { | ||
| Log.e(TAG, "Error launching CustomerCenterTrampolineActivity", t); | ||
| RevenueCatUI.sendCustomerCenterError(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.