@@ -46,27 +46,35 @@ class LenraOauth2Helper extends OAuth2Helper {
46
46
}
47
47
}
48
48
49
- /// Get the custom uri scheme of the app for the current plateform.
49
+ const defaultApplicationId = "com.example.app" ;
50
+
51
+ /// Get the custom uri scheme of the app for the current platform.
50
52
String getPlatformCustomUriScheme ({
51
- String androidApplicationId = "com.example.app" ,
53
+ @Deprecated ("Use applicationId instead." ) String androidApplicationId = defaultApplicationId,
54
+ String applicationId = defaultApplicationId,
52
55
int oauthRedirectPort = 10000 ,
53
56
}) {
54
57
// It is important to check for web first because web is also returning the TargetPlatform of the device.
55
58
if (! kIsWeb) {
56
- if (defaultTargetPlatform == TargetPlatform .windows ||
57
- defaultTargetPlatform == TargetPlatform .linux) {
59
+ if (defaultTargetPlatform == TargetPlatform .windows || defaultTargetPlatform == TargetPlatform .linux) {
58
60
// Apparently the customUriScheme should be the full uri for Windows and Linux for oauth2_client to work properly
59
61
return "http://localhost:$oauthRedirectPort " ;
60
62
} else if (defaultTargetPlatform == TargetPlatform .android || defaultTargetPlatform == TargetPlatform .iOS) {
61
- return androidApplicationId;
63
+ // If androidApplicationId has been set to something different from its default value, use it instead of applicationId. (deprecation handling)
64
+ if (androidApplicationId != defaultApplicationId) {
65
+ return androidApplicationId;
66
+ }
67
+
68
+ return applicationId;
62
69
}
63
70
}
64
71
return "http" ;
65
72
}
66
73
67
- /// Get the custom uri scheme of the app for the current plateform .
74
+ /// Get the custom uri scheme of the app for the current platform .
68
75
String getPlatformRedirectUri ({
69
- String androidApplicationId = "com.example.app" ,
76
+ @Deprecated ("Use applicationId instead" ) String androidApplicationId = defaultApplicationId,
77
+ String applicationId = defaultApplicationId,
70
78
int oauthRedirectPort = 10000 ,
71
79
String oauthRedirectPath = "/redirect.html" ,
72
80
}) {
@@ -75,7 +83,12 @@ String getPlatformRedirectUri({
75
83
return "${Uri .base .scheme }://${Uri .base .host }:${Uri .base .port }$oauthRedirectPath " ;
76
84
}
77
85
if (defaultTargetPlatform == TargetPlatform .android || defaultTargetPlatform == TargetPlatform .iOS) {
78
- return "$androidApplicationId ://" ;
86
+ // If androidApplicationId has been set to something different from its default value, use it instead of applicationId. (deprecation handling)
87
+ if (androidApplicationId != defaultApplicationId) {
88
+ return "$androidApplicationId ://" ;
89
+ }
90
+
91
+ return "$applicationId ://" ;
79
92
}
80
93
81
94
return "http://localhost:$oauthRedirectPort $oauthRedirectPath " ;
0 commit comments