j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

[iOS] Opening modal from AppStore for auto renewable subscription with links to terms and services #782

Closed ivanov84 closed 5 years ago

ivanov84 commented 5 years ago

system info

Cordova 7.1.0
Cordova-IOS: 4.5.5
Device: iPhone iOs 12.1.1
Plugin Version: 7.1.3
Framework: Ionic 4

Expected behavior

After AppStore page clicking on "Buy" (promoting in app purchase item) opens my app and then opens a modal page with links terms and services with my "Buy" buttons on my modal page

Observed behavior

After AppStore page clicking on "Buy" (promoting in app purchase item) opens my app and user sees a direct (ios native) purchase process

Steps to reproduce

Make IAP promoting active in store and press BUY btn from AppStore your app page

My problem

Apple Review team said that I have to open modal with subscription explanation if user clicks on purchase button in App Store page and was directed to my app. So after this my app opens and user see opened bar with (ios native) purchase process.

Dexus commented 5 years ago

I think you need to rebuild you page design, and make thus links global available. Don’t know what you are doing at start, and if you read the requirements from Apple...

So please make some screens how you implement it. And than I can say you your problem. ;)

Von meinem iPhone gesendet

Am 16.12.2018 um 15:26 schrieb ivanov84 notifications@github.com:

system info

Cordova 7.1.0 Cordova-IOS: 4.5.5 Device: iPhone iOs 12.1.1 Plugin Version: 7.1.3 Framework: Ionic 4 Expected behavior

After AppStore page clicking on "Buy" (promoting in app purchase item) opens my app and then opens a modal page with links terms and services with my "Buy" buttons on my modal page

Observed behavior

After AppStore page clicking on "Buy" (promoting in app purchase item) opens my app and user sees a direct (ios native) purchase process

Steps to reproduce

Make IAP promoting active in store and press BUY btn from AppStore your app page

My problem

Apple Review team said that I have to open modal with subscription explanation if user clicks on purchase button in App Store page and was directed to my app. So after this my app opens and user see opened bar with (ios native) purchase process.

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ivanov84 commented 5 years ago

Sorry for my english... I thought my words describe all well...

  1. I have app
  2. I have button on main screen - press it and purchase modal opens with url links to TOS and "buy subscription" buttons
  3. When I click on buy button in AppStore - I redirect to app - when app is loaded native ios bar with purchase process opens
  4. But Review team wants after that specific redirection from AppStore opened purchase modal - I need trigger that opens ios native bar (it means what appears after you call store.order("full version"); in classic purchase process in app)
ivanov84 commented 5 years ago

Ready! That is Apple Review does not like: 666

yankustefan commented 5 years ago

Hi @ivanov84

I ran into the same issue recently and was also a bit confused at first.

The AppStore is now much more strict. I had to revise the subscription a few times until it got green lit.

The standard slide-up in your gif is apparently not enough anymore. Before triggering the subscription process, you have to clearly mention:

To accomplish this, I had to change the subscription flow as well. Now, tapping "subscribe" first opens a modal window, containing all necessary information. The actual purchase is triggered from there.

Below I attached a screenshot where you can see how I did it. (see grey text below subscribe button)

Furthermore, you have to have a link to your Terms of Service and Privacy Policy. If you have an "About this app" page inside your app, it should be okay to place it there, but I also added it to the modal.

image

I hope that helps.

ivanov84 commented 5 years ago

@yankustefan, thank you, you understand what I am talking about. But how to get this trigger in cordova-plugin-purchase plugin? It's triggered automatically in cordova-plugin-purchase after ckicking from AppStore page.

ivanov84 commented 5 years ago

@j3k0, may be it's possible to create method like:

store.when("week_sub").redirected(function (product) {
    openSubscriptionModal();
});

or

store.redirected(function (product) {
    if (product.alias != "week_sub") {
        store.order(product.alias);
    }
    else {
        openSubscriptionModal();
    }
});
j3k0 commented 5 years ago

@ivanov84 I'm not sure I get what you are trying to do.

If what you want is to show the modal window when the user clicks the "Buy" (or "Subscribe") button, just don't call store.order(...) from this button. Have this button open a modal window with all the required details about the subscription, in which you have a "Subscribe" button that calls store.order(...).

ivanov84 commented 5 years ago

@j3k0 I didn't think it could be so difficult to explain...

After clicking Buy button in Apple Store - my app opens and ios native purchase process starts immediately and automatically - I need to start purchase after clicking BUY on my modal.

ivanov84 commented 5 years ago

@j3k0 I need to define that app opens from "Clicked Buy button in Apple Store" and stop running ios native purchase process after my app has opened. Also for consumable products I want to stay starting automaticly ios native purchase proccess.

j3k0 commented 5 years ago

@ivanov84 OK my Bad! I missed the fact you're initiating the purchase from the App Store (even though you mentioned that a couple of times).

Now I understand. I'm sorry promoted in-app purchases are not yet supported by the plugin.

j3k0 commented 5 years ago

It's strange, the recommandations from Apple is actually NOT to show intermediary screens.

From https://developer.apple.com/app-store/promoting-in-app-purchases/

When a user starts an in-app purchase on the App Store, they are taken into your app to continue the transaction. Consider presenting the payment sheet as soon as they are in the app to make the process of completing their purchase as easy as possible. Avoid unnecessary interstitials and messaging, as each extra step you require may decrease the likelihood that the user will complete the purchase.

Can you share the exact message you got from the apple review team?

j3k0 commented 5 years ago

Note for implementation

The plugin will have to implement this delegate method: https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/2877502-paymentqueue?language=objc

ivanov84 commented 5 years ago

2018-12-18_13-49-14

j3k0 commented 5 years ago

@ivanov84 Thanks. I won't be able to work on this before the end of the month. Anyone up for the task until then?

In the meantime, I'm afraid you will have to disable promoting your subscription in the appstore.

ivanov84 commented 5 years ago

@j3k0 I did it and told them about it but they don't answer me.... 😭 But in my app there is huge bug fixing.... 😭😭😭

yankustefan commented 5 years ago

@ivanov84 https://github.com/ivanov84, I would keep it simple. Instead of automatically triggering the purchase from outside the app, point to a page in your app where you describe your subscription first. Then have a subscribe button there, that triggers the purchase. I assume that your setup – triggering a purchase without a β€žwarningβ€œ beforehand, is what Apple opposes. It is probably less a technical problem but a UX issue. To me, it seems reasonable to let the user first learn more about your product before they agree to purchase.

On Tue, Dec 18, 2018 at 18:01 ivanov84 notifications@github.com wrote:

@yankustefan https://github.com/yankustefan, thank you, you understand what I am talking about. But how to get this trigger in cordova-plugin-purchase plugin? It's triggered automatically in cordova-plugin-purchase after ckicking from AppStore page.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/j3k0/cordova-plugin-purchase/issues/782#issuecomment-448146534, or mute the thread https://github.com/notifications/unsubscribe-auth/AH7zReucsNx1DUkcXuNjDaDmesb0TSivks5u6K76gaJpZM4ZVQOw .

ivanov84 commented 5 years ago

@yankustefan Am I right you are talking about cordova-plugin-purchase plugin? Or you mean alternative plugin? Or you think that I can edit code in XCode?

Actually I can use plugin with methods that list in plugin API.... And use workflow that presentes in plugin... So I cannot control redirection from Apple Store...

yankustefan commented 5 years ago

Since I am not the developer of this plugin, I am not sure if your case is actually an issue related to the plugin code. I just wanted to share that in my case, I was able to resolve this by adjusting the UI and including the required description.

ivanov84 commented 5 years ago

@yankustefan You are right to detail the true rejection of the Apple Review team. But perhaps you just don't understand that I am talking about redirection event from Apple Store. If I open a modal page with subscription every time user opens the app - this will be really bad experience...

yankustefan commented 5 years ago

Yes, I did not get that. Sorry. It seems that - according to the plugin maintainer - this feature has yet to be implemented.

ivanov84 commented 5 years ago

@yankustefan It's Ok. Today I am gonna learn how to edit Objective-C.... I remember when I edit java... Again a challenge.... 😭😭😭

ivanov84 commented 5 years ago

I implemented a workaround. Here are the steps to do this:

  1. add this to InAppPurchase.m:

    - (BOOL)paymentQueue:(SKPaymentQueue *)queue shouldAddStorePayment:(SKPayment *)payment forProduct:(SKProduct *)product {
    // Another code here
    
    if ([productId isEqualToString:@"com.bestapp.1weeksubscription"]) {
        NSString *js = @"window.storekit.redirectionFromStoreDone.apply(window.storekit)";
        [self.commandDelegate evalJs: js];
        return NO;
    }
    else {
        return YES;
    }
    }
  2. add this to ios-bridge.js:

    
    this.options = {
    // Another code here
    redirectionDone: options.redirectionDone || noop,
    // Another code here
    }; 

InAppPurchase.prototype.redirectionFromStoreDone = function () { protectCall(this.options.redirectionDone, 'options.redirectionDone'); };


3. add this to **ios-adapter.js**:

storekit.init({ // Another code here redirectionDone: storekitAppleStoreRedirectionDone, // Another code here }, storekitReady, storekitInitFailed);

function storekitAppleStoreRedirectionDone() { store.log.info("ios -> redirection done"); store.trigger('redirection-done'); }


3. add this to your code:

store.when('redirection-done', () => { this.openMySubscriptionModalPage(); });

j3k0 commented 5 years ago

Thanks @ivanov84 , that is be a great start for a more generic implementation.

Of course this line: if ([productId isEqualToString:@"com.bestapp.1weeksubscription"]) { cannot be as-is in the plugin.

Do you think generating a redirection for all subscriptions would be good enough? I'm not sure of the ins-and-outs of doing this.

Maybe the list of products to enable redirections has to be more customizable? Opinion on this anyone?

Dexus commented 5 years ago

Good Start! But you need a generic one and maybe this can also be with register the product not only for subscription.

Von meinem iPhone gesendet

Am 19.12.2018 um 18:04 schrieb Jean-Christophe Hoelt notifications@github.com:

Thanks @ivanov84 , that is be a great start for a more generic implementation.

Of course this line: if ([productId isEqualToString:@"com.bestapp.1weeksubscription"]) { cannot be as-is in the plugin.

Do you think generating a redirection for all subscriptions would be good enough? I'm not sure of the ins-and-outs of doing this.

Maybe the list of products to enable redirections has to be more customizable? Opinion on this anyone?

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ivanov84 commented 5 years ago

@j3k0 @Dexus Thanks πŸ˜„

I think that idea to push via "register" - could be good. Because only "auto-renewable" subscriptions need to direct to subscription description modal page.

Also when I tested on old iPad this trigger fired before plguin initialized. So I think it's nessasary to add property which should be fired when plugin initialization finished and "paymentQueue" event finished too.