Skip to content

Commit eb1a5b6

Browse files
align with core changes
1 parent 685822c commit eb1a5b6

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private void initializeNotificationWorker(Context context) {
238238
container.setWebViewClient(new WebViewClient() {
239239
@Override
240240
public void onPageFinished(WebView view, String url) {
241-
String jsCheckApi = "(() => typeof window.CHTCore.AndroidApi.v1.notificationTasks === 'function')();";
241+
String jsCheckApi = "(() => typeof window.CHTCore.AndroidApi.v1.taskNotifications === 'function')();";
242242
container.evaluateJavascript(jsCheckApi, new ValueCallback<String>() {
243243
@Override
244244
public void onReceiveValue(String s) {

src/main/java/org/medicmobile/webapp/mobile/NotificationWorker.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
import static org.medicmobile.webapp.mobile.MedicLog.log;
44

55
import android.annotation.SuppressLint;
6-
import android.app.NotificationChannel;
7-
import android.app.NotificationManager;
86
import android.content.Context;
9-
import android.os.Build;
107
import android.os.Handler;
118
import android.os.Looper;
12-
import android.util.Log;
139
import android.webkit.JavascriptInterface;
1410
import android.webkit.WebSettings;
1511
import android.webkit.WebView;
1612
import android.webkit.WebViewClient;
1713

1814
import androidx.annotation.NonNull;
19-
import androidx.core.app.NotificationCompat;
2015
import androidx.work.Worker;
2116
import androidx.work.WorkerParameters;
2217

@@ -28,8 +23,7 @@
2823
import java.util.concurrent.TimeUnit;
2924

3025
public class NotificationWorker extends Worker {
31-
final String TAG = "NOTIFICATION_WORKER";
32-
final int EXECUTION_TIMEOUT = 20;
26+
final int EXECUTION_TIMEOUT = 10;
3327

3428
public NotificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
3529
super(context, workerParams);
@@ -52,8 +46,8 @@ public Result doWork() {
5246
public void onPageFinished(WebView view, String url) {
5347
String js = "(async function (){" +
5448
" const api = window.CHTCore.AndroidApi;" +
55-
" if (api && api.v1 && api.v1.notificationTasks) {" +
56-
" const tasks = await api.v1.notificationTasks();" +
49+
" if (api && api.v1 && api.v1.taskNotifications) {" +
50+
" const tasks = await api.v1.taskNotifications();" +
5751
" CHTNotificationBridge.onJsResult(JSON.stringify(tasks));" +
5852
" }" +
5953
"})();";
@@ -65,9 +59,9 @@ public void onPageFinished(WebView view, String url) {
6559
try {
6660
boolean completed = latch.await(EXECUTION_TIMEOUT, TimeUnit.SECONDS);
6761
if (completed) {
68-
log(TAG, "notification worker ran successfully!");
62+
log(getApplicationContext(), "notification worker ran successfully!");
6963
} else {
70-
log(TAG, "notification worker taking too long to complete");
64+
log(getApplicationContext(), "notification worker taking too long to complete");
7165
}
7266
} catch (InterruptedException e) {
7367
log(e, "error: notification worker interrupted");

0 commit comments

Comments
 (0)