Skip to content

Commit e26762e

Browse files
authored
Merge pull request #7 from hogangnono/feature/customscheme
[HGNN-7039] 광고 BM 배너 관련 안드로이드 앱 작업
2 parents 59540f5 + 81fd47a commit e26762e

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-inappbrowser",
3-
"version": "5.0.15-hogangnono",
3+
"version": "5.0.16-hogangnono",
44
"description": "Cordova InAppBrowser Plugin",
55
"types": "./types/index.d.ts",
66
"cordova": {

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2222
id="cordova-plugin-inappbrowser"
23-
version="5.0.15-hogangnono">
23+
version="5.0.16-hogangnono">
2424

2525
<name>InAppBrowser</name>
2626
<description>Cordova InAppBrowser Plugin</description>

src/android/InAppBrowser.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ public void onResume(boolean multitasking) {
380380
if (shouldPauseInAppBrowser) {
381381
inAppWebView.onResume();
382382
}
383+
384+
// onelink를 통해 이동 후, 앱에 재 진입 시, 기존 페이지로 전환
385+
if(edittext.getText().toString().contains("onelink.me")) {
386+
goBack();
387+
}
383388
}
384389

385390
/**
@@ -1090,6 +1095,11 @@ public void postMessage(String data) {
10901095

10911096
if (overrideUserAgent != null) {
10921097
settings.setUserAgentString(overrideUserAgent);
1098+
}else{
1099+
//onelink에서 customscheme가 아닌 intent://사용하기 위해서 UA에서 wv를 제거
1100+
String ua = settings.getUserAgentString();
1101+
String newUA = ua.replace("; wv","");
1102+
settings.setUserAgentString(newUA);
10931103
}
10941104
if (appendUserAgent != null) {
10951105
settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent);
@@ -1412,28 +1422,24 @@ else if (url.startsWith(HOGANGNONO_SCHEME)) {
14121422
}
14131423
// Supports Intent:// scheme. It usually used on above 4 version.
14141424
else if (url.startsWith(INTENT_PROTOCOL_START)) {
1415-
final int customUrlStartIndex = INTENT_PROTOCOL_START.length();
1416-
final int customUrlEndIndex = url.indexOf(INTENT_PROTOCOL_INTENT);
1417-
1418-
if (customUrlEndIndex < 0) {
1419-
return false;
1420-
} else {
1421-
final String customUrl = url.substring(customUrlStartIndex, customUrlEndIndex);
1422-
1425+
// intent:// 실행코드 변경
1426+
try {
1427+
Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
14231428
try {
1424-
cordova.getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(customUrl)));
1425-
} catch (ActivityNotFoundException e) {
1426-
if (url.contains("kakaolink://send")) {
1427-
cordova.getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(GOOGLE_PLAY_STORE_PREFIX + "com.kakao.talk")));
1428-
return true;
1429+
Uri uri = Uri.parse(intent.getDataString());
1430+
cordova.getActivity().startActivity(new Intent(Intent.ACTION_VIEW, uri));
1431+
} catch(Exception e) {
1432+
LOG.e(LOG_TAG, "Error startActivity Intent " + url + ": " + e.toString());
1433+
String fallbackUrl = intent.getStringExtra("browser_fallback_url");
1434+
if(fallbackUrl != null) {
1435+
LOG.d(LOG_TAG, "FallbackUrl : " + fallbackUrl);
1436+
cordova.getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(fallbackUrl)));
14291437
}
1430-
final int packageStartIndex = customUrlEndIndex + INTENT_PROTOCOL_INTENT.length();
1431-
final int packageEndIndex = url.indexOf(INTENT_PROTOCOL_END);
1432-
final String packageName = url.substring(packageStartIndex, packageEndIndex < 0 ? url.length() : packageEndIndex).replace("package=", "");
1433-
cordova.getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(GOOGLE_PLAY_STORE_PREFIX + packageName)));
14341438
}
1435-
return true;
1439+
} catch(Exception e) {
1440+
LOG.e(LOG_TAG, "Error parseUri " + url + ": " + e.toString());
14361441
}
1442+
return true;
14371443
}
14381444
// Test for whitelisted custom scheme names like mycoolapp:// or twitteroauthresponse:// (Twitter Oauth Response)
14391445
else if (!url.startsWith("http:") && !url.startsWith("https:") && url.matches("^[A-Za-z0-9+.-]*://.*?$")) {

0 commit comments

Comments
 (0)