Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Redirect URL with HTTPS in iOS doesn't work

I'm creating a iOS and Android mobile application using the Ionic framework.

I've configured everything for the OAuth 2.0 and it works fine for Android, but in the case of iOS, I'm having problems launching the app again after the Authentication is completed. This is because Fitbit requires using https in the redirect URL instead of a custom URL (for example myAppName://callback, if I use the custom URL it works) and Safari browser tries to go to this URL instead of opening the app.

Could you please help me here.

Best Answer
0 Votes
5 REPLIES 5

Hi @AGallego,

Welcome to the forums!

Could you clarify the behavior you're experiencing on iOS after the user consents in the authorization flow? After consent is granted, does an error appear, preventing the user from being redirected back to your application? Could you also PM your redirect URL and client ID to me? 

Thanks!

Best Answer
0 Votes

Hi @JohnFitbit,

the client ID is "23RVJ8", the expected behaviour is like in Android (go to the browser, introduce google credentials, be redirected to the redirect URL and automatically return to the app). In the case of iOS, I tested with 2 different redirect URLs (here the snapshots with results obtained):

 redirect url "ubicardio"redirect url "ubicardio"redirect url "https"redirect url "https"

  1. https://fitbitcallback in this case after the redirection the safari browser says it can't open the URL, and my app doesn't receive the redirect URL event (I have a appUrlOpen listener). This is the configuration in the Info.plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
</array>
  1. ubicardio://fitbitcallbak in this case after the redirection the safari browser turns to white, and my app receives the redirect URL event (I have an appUrlOpen listener). This is the configuration in the Info.plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>ubicardio</string>
</array>
</dict>
</array>
 
I don't understand why with https doesn't work and why it can't open the app as in Android.
 
Thanks!
Best Answer
0 Votes

Hi @AGallego 

In your iOS application, are you using the SFSafariViewController class when displaying the authorization page?   See Displaying the Authorization Page.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @GordonFitbit,

yes, I'm using the browser plugin from Capacitor which uses SFSafariViewControlled. Everything works as expected, I can see the Fitbit Login in both, Android and iOS, and the redirection link includes the codes I need for obtaining Tokens.

The problem is related to the redirection to the app once the login and redirection are finished. When I configure it as redirect URL ubicardio:// it doesn't try to open the app or show any message, but when I paste in the Safari browser ubicardio:// it asks me If I want to open the app (this is the first problem).

The second problem is that Fitbit says the redirect URL should be https, but when you are programming mobile applications it's usual to configure "appName://" as the redirect URL (as in the case of Fitbit, fitbit://).

An option that works for me is to include an intermediate website (https) as the redirect URL which is in charge of managing the redirection and opening of the app. Is this approach valid?

Best,

Best Answer
0 Votes

You can use custom domains, such as ubicardio://.  However, the URL needs to be absolute and point to a specific location.   For example, ubicardio://myAppLocation or ubicardio://myAppLocation/callback.   See if changing your redirect URL to one of those resolves the problem.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer