33import static org .medicmobile .webapp .mobile .MedicLog .log ;
44
55import android .annotation .SuppressLint ;
6- import android .app .NotificationChannel ;
7- import android .app .NotificationManager ;
86import android .content .Context ;
9- import android .os .Build ;
107import android .os .Handler ;
118import android .os .Looper ;
12- import android .util .Log ;
139import android .webkit .JavascriptInterface ;
1410import android .webkit .WebSettings ;
1511import android .webkit .WebView ;
1612import android .webkit .WebViewClient ;
1713
1814import androidx .annotation .NonNull ;
19- import androidx .core .app .NotificationCompat ;
2015import androidx .work .Worker ;
2116import androidx .work .WorkerParameters ;
2217
2823import java .util .concurrent .TimeUnit ;
2924
3025public 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