Skip to content

Commit

Permalink
Merge branch 'main' into #75-deeplink-add
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Sep 11, 2023
2 parents 05a9750 + 569399b commit 8ec6481
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MainActivity: FlutterActivity() {
val intent = Intent.parseUri(call.arguments as String, Intent.URI_INTENT_SCHEME)

if (intent.resolveActivity(packageManager) != null) {
packageManager.getLaunchIntentForPackage(""+intent.getPackage())
startActivity(intent)
result.success(null)
} else {
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
9 changes: 9 additions & 0 deletions lib/utils/fcmToken.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class FcmToken {

Future<void> init() async {
final token = await FirebaseMessaging.instance.getToken();
_dio.interceptors
.add(InterceptorsWrapper(onRequest: (options, handler) async {
options.headers["Origin"] = options.uri.origin;
return handler.next(options);
}, onResponse: (response, handler) async {
return handler.next(response);
}, onError: (error, handler) async {
return handler.next(error);
}));

if (token == null) {
this.token = '';
Expand Down
30 changes: 15 additions & 15 deletions lib/utils/remoteConfigController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:package_info/package_info.dart';
class RemoteConfigController {
String backUrl;
String frontUrl;
String ios_version;
String android_version;
String iosVersion;
String androidVersion;

static RemoteConfigController? _instance;

Expand All @@ -14,28 +14,28 @@ class RemoteConfigController {
RemoteConfigController._internal(
{required this.backUrl,
required this.frontUrl,
required this.ios_version,
required this.android_version});
required this.iosVersion,
required this.androidVersion});

factory RemoteConfigController(
{String? backUrl,
String? frontUrl,
String? ios_version,
String? android_version}) {
String? iosVersion,
String? androidVersion}) {
if (frontUrl == null ||
backUrl == null ||
ios_version == null ||
android_version == null) {
iosVersion == null ||
androidVersion == null) {
return _instance ??= RemoteConfigController._internal(
backUrl: '', frontUrl: '', ios_version: '', android_version: '');
backUrl: '', frontUrl: '', iosVersion: '', androidVersion: '');
}
_instance = RemoteConfigController._internal(
backUrl: backUrl,
frontUrl: frontUrl,
ios_version: ios_version,
android_version: android_version);
iosVersion: iosVersion,
androidVersion: androidVersion);
return _instance ??= RemoteConfigController._internal(
backUrl: '', frontUrl: '', ios_version: '', android_version: '');
backUrl: '', frontUrl: '', iosVersion: '', androidVersion: '');
}

Future<void> init() async {
Expand All @@ -47,7 +47,7 @@ class RemoteConfigController {
));
await remoteConfig.setDefaults({
"back_url": "https://taxi.sparcs.org/api/",
"front_url": "https://taxi.sparcs.org",
"front_url": "https://taxi.sparcs.org/",
"version": value.version,
"ios_version": value.version,
});
Expand All @@ -56,8 +56,8 @@ class RemoteConfigController {

this.backUrl = remoteConfig.getString("back_url");
this.frontUrl = remoteConfig.getString("front_url");
this.android_version = remoteConfig.getString("version");
this.ios_version = remoteConfig.getString("ios_version");
this.androidVersion = remoteConfig.getString("version");
this.iosVersion = remoteConfig.getString("ios_version");

return;
}
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class Token {
Future<void> init() async {
accessToken = (await getAccessTokenFromStorage()) ?? '';
refreshToken = (await getRefreshTokenFromStorage()) ?? '';
_dio.interceptors.add(CookieManager(_cookieJar));
_dio.interceptors
.add(InterceptorsWrapper(onRequest: (options, handler) async {
options.headers["Origin"] = options.uri.origin;
return handler.next(options);
}, onResponse: (response, handler) async {
return handler.next(response);
}, onError: (error, handler) async {
return handler.next(error);
}));
}

Future<void> setAccessToken({required String accessToken}) async {
Expand Down
45 changes: 34 additions & 11 deletions lib/views/taxiView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ class TaxiView extends HookWidget {
try {
if (Platform.isIOS) {
if (int.parse(
RemoteConfigController().ios_version.replaceAll(".", "")) >
RemoteConfigController().iosVersion.replaceAll(".", "")) >
int.parse(value.version.replaceAll(".", ""))) {
isMustUpdate.value = true;
}
} else {
if (int.parse(RemoteConfigController()
.android_version
.androidVersion
.replaceAll(".", "")) >
int.parse(value.version.replaceAll(".", ""))) {
isMustUpdate.value = true;
Expand All @@ -240,8 +240,9 @@ class TaxiView extends HookWidget {
if (Token().accessToken != '') {
await Token().deleteAll();
}
isLogin.value = false;
_cookieManager.deleteAllCookies();
isAuthLogin.value = false;
isLogin.value = false;
isFirstLogin.value = false;
LoadCount.value += 1;
} else {
Expand Down Expand Up @@ -296,6 +297,24 @@ class TaxiView extends HookWidget {
AndroidOverScrollMode.OVER_SCROLL_NEVER),
ios: IOSInAppWebViewOptions(disallowOverScroll: true)),
// initialUrlRequest: URLRequest(url: Uri.parse(address)),
shouldOverrideUrlLoading: (controller, navigationAction) async {
var newHeaders = Map<String, String>.from(
navigationAction.request.headers ?? {});
if (!newHeaders.containsKey("Referer") &&
navigationAction.request.url.toString() !=
'about:blank') {
newHeaders['Referer'] =
navigationAction.request.url.toString();
newHeaders['Origin'] = RemoteConfigController().frontUrl;
var newRequest = navigationAction.request;
newRequest.headers = newHeaders;
await controller.loadUrl(urlRequest: newRequest);

return NavigationActionPolicy.CANCEL;
}

return NavigationActionPolicy.ALLOW;
},
onWebViewCreated: (InAppWebViewController webcontroller) async {
_controller.value = webcontroller;
_controller.value?.addJavaScriptHandler(
Expand All @@ -308,13 +327,17 @@ class TaxiView extends HookWidget {
}
// 로그인 성공 시 / 기존 토큰 삭제 후 새로운 토큰 저장
if (!isAuthLogin.value) {
await Token().setAccessToken(
accessToken: arguments[0]['accessToken']);
await Token().setRefreshToken(
refreshToken: arguments[0]['refreshToken']);
await FcmToken()
.registerToken(arguments[0]['accessToken']);
isAuthLogin.value = true;
if (arguments[0]['accessToken'] != null &&
arguments[0]['refreshToken'] != null) {
await Token().deleteAll();
await Token().setAccessToken(
accessToken: arguments[0]['accessToken']);
await Token().setRefreshToken(
refreshToken: arguments[0]['refreshToken']);
await FcmToken()
.registerToken(arguments[0]['accessToken']);
isAuthLogin.value = true;
}
}
return;
},
Expand Down Expand Up @@ -469,7 +492,7 @@ class TaxiView extends HookWidget {
// 될 때까지 리로드
if (!isLoaded.value && LoadCount.value < 10) {
LoadCount.value++;
} else if (isServerError.value == false) {
} else if (isServerError.value == false && code != 102) {
Fluttertoast.showToast(
msg: "서버와의 연결에 실패했습니다.",
toastLength: Toast.LENGTH_SHORT,
Expand Down

0 comments on commit 8ec6481

Please sign in to comment.