blob: 66bb81bf6ba63c28b51c0bc50363597eb1e010fd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package io.coinos;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Bridge;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginHandle;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.CookieManager;
public class MainActivity extends BridgeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri data = intent.getData();
if (data != null) {
String url = data.toString();
Bridge bridge = getBridge();
if (bridge != null) {
String encodedUrl = Uri.encode(url);
String destinationUrl = "https://coinos.io/send/" + encodedUrl;
bridge.getWebView().post(() -> {
bridge.getWebView().loadUrl(destinationUrl);
});
}
}
}
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri data = intent.getData();
if (data != null) {
String url = data.toString();
// Dispatch deep link when app is already open
Bridge bridge = getBridge();
if (bridge != null) {
String encodedUrl = Uri.encode(url);
String destinationUrl = "https://dev.coinos.io/send/" + encodedUrl;
bridge.getWebView().post(() -> {
bridge.getWebView().loadUrl(destinationUrl);
});
}
}
}
}
@Override
public void onPause() {
super.onPause();
CookieManager.getInstance().flush();
}
}
|