getkevin / kevin-flutter

MIT License
0 stars 0 forks source link

setDeepLinkingEnabled has no effect #15

Open KestasVenslauskas opened 2 years ago

KestasVenslauskas commented 2 years ago

As I was testing on Android & iOS I think I didnt find a purpose for 'setDeepLinkingEnabled' method. Yes it sets this flag in code package and also calls native method to set the flat on native SDK itself, but what is the usecase for this?

I can actually set auth & payment redirect urls as https://www.google.com and the flow will still ignore this. Looking on android code it makes sense because it does not even look at redirect url since it uses activity result from AccountSessionActivity. Maybe 'deepLinkingEnabled' flag is used somewhere internally on Kevin native SDK's but is this even required here to be exposed in flutter package?

It's great that we do not need to setup deepLinking manually but is this intended not to have option for any other redirect url?

edgar-zigis commented 2 years ago

Hey @KestasVenslauskas , deep linking will only work after the proper deep link registering within your application. Registration ways on the native applications can be found in our docs here.

KestasVenslauskas commented 2 years ago

@edgar-zigis I had the proper deepLink setup from previous examples it was "kevin://" I tought it works because I left it there and callback urls matched the schema but after removing intent-filters from androids manifest and changing callback url it was still working the same. Before this I had no "kevin://.." deepLink implementation on iOS, but iOS works the same - it just does a simple callback to flutter code.

What would be the use case or advantage to have a proper deepLink setup right now?

KestasVenslauskas commented 2 years ago

@edgar-zigis Just tried with my own deepLinking setup. Changing this flag tries to open a deepLink even if 'deepLinkingEnabled' is false.

Also I think deepLinking is not working as expected because another instance of my app is opened from deep link instead going back to the same app instance and passing intent result.

antons-zubkovs commented 2 years ago

@KestasVenslauskas hi! Since our current example does not support account linking yet (we are working on a new refactored example app), I tested deep linking with in app payments.

In flutter's app main() method I added:

  await Kevin.setDeepLinkingEnabled(true);
  await KevinPayments.setPaymentsConfiguration(
    const KevinPaymentsConfiguration(
      callbackUrl: 'kevin://redirect.payment',
    ),
  );

In flutter's app android manifest file:

 <activity
           android:name="eu.kevin.inapppayments.paymentsession.PaymentSessionActivity"
           android:exported="true">
           <intent-filter>
               <action android:name="android.intent.action.VIEW" />
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />
               <data
                   android:host="redirect.payment"
                   android:scheme="kevin" />
           </intent-filter>
 </activity>

Then I proceeded to make a payment using Revolut bank. After the payment, redirect link was opened and example app existing instance was opened as well.

Could you share some code snippets with your deep linking setup, so I could investigate it later?

KestasVenslauskas commented 2 years ago

@antons-zubkovs Since I did not used an example app, but just double checked the code I tested both accountLinking & in-app-payments. Both works fine.

About the deep linking... I tested few links and behaviour is still strange.

  1. Lets say we initialise accoutLinking with callbackUrl A and set calbackUrl in AccountsConfiguration as B. Then after account linking is successfull I will see a webview with url A. Why B is ignored?
  2. Lets say we initialise accoutLinking with callbackUrl A and set calbackUrl in AccountsConfiguration as A. Then after account linking is successfull I will get a simple callback to flutter code without deepLinking just using this method channel. I don't see any code touching deep linking feature inside your flutter packages.
  3. Lets say my deep link scheme is myApp:/... with a single / but I can't set a callbackUrl with a single / during auth init api call it gives me an error it has to be myApp://.... So I tried sending myApp://... to auth init and set myApp:/... inside AccountsConfiguration. This way Kevin tries to redirect me to my deepLinking by opening new instance of my app...
  4. In all of the cases mentioned before setting deepLinkingEnabled either to true or false does not impact any behaviour...

I cannot fully test deep linking because of the points mentioned above but the other question is what is the expected flow here? Is it actually needed?

I wonder what happens when deepLinkingEnabled is set to false but I will pass callbackUrl as my deepLink url?

antons-zubkovs commented 2 years ago

@KestasVenslauskas

  1. callbackUrl must be the same for your accountLinking initialisation and AccountsConfiguration object
  2. When you set Kevin.setDeepLinkingEnabled(true), provide callbackUrl in configuration and set that url in intent filter, you should not worry about handling deep linking yourself, as it is handled by the SDK, all you get - is a response from the flutter plugin (using method channel mentioned above). What happens in details:
  1. To have a proper scheme, you have to use double slash (you check that doc). Your intent filter's scheme and host and concatenated like scheme://host.
KestasVenslauskas commented 2 years ago

@antons-zubkovs As I understand Kevin.setDeepLinkingEnabled(true) is just for auth/payment app redirection vs brower and has nothing to do with the apps deepLink which is initializing the auth/payment? Maybe it's worth mentioning this in the docs or just as comment in the code?

What I'm trying to achieve here is simply callback to our backend for a successfull payment, which does not actually require deepLinking here since this SDK automatically goes back to the app if links match, so then I can send a request to the backend from a client app after the callback from Kevin SDK is received in flutter code. But anyway links get ignored if they are equal so I'm trying to understand the correct flow here. I tought the callback url should be to our backend endpoint and after that our backend should redirect to our app via deep link.

antons-zubkovs commented 2 years ago

@KestasVenslauskas regarding Kevin.setDeepLinkingEnabled(true), probably we will have to improve our docs on that point.

The way to achieve your desired behaviour - you can have some endpoint on your BE to confirm that the payment was finished, when you get the result from the flutter plugin.

KestasVenslauskas commented 2 years ago

@antons-zubkovs Just tried Kevin.setDeepLinkingEnabled(true) on a real device that has "SwedBank" app. But it did not tried to open "SwedBank" app during auth/payment. Maybe it's because project is still in sandbox mode?

antons-zubkovs commented 2 years ago

@KestasVenslauskas it tried to open SwedBank app, though it does not support it, that's why flow was continued in a web view. You can try to check it with Revolut bank with/without setDeepLinkingEnabled and you will see the difference.

KestasVenslauskas commented 2 years ago

@antons-zubkovs I do have a Revolut on my device. Just tried with setDeepLinkingEnabled either true or false I just see few flashes of webview like "waiting for payment..." and then it goes back with a success callback. Revolut app was not opened.

antons-zubkovs commented 2 years ago

@KestasVenslauskas did you set isSandbox as true? That could be the reason of that behaviour. Banks behave differently in a sandbox mode, so it could be Revolut's behaviour.

KestasVenslauskas commented 2 years ago

@antons-zubkovs No if I set isSandbox to true I see only webview with "page not found" after starting auth/payment. But our project is still in sandbox mode. Maybe this is also a reason?

antons-zubkovs commented 2 years ago

@KestasVenslauskas that also could be the reason, yes.