Repository navigation
Replies: 1 comment
|
tbh context emang ga akan pernah ada di background handler. handler itu jalan di isolate terpisah tanpa widget tree, jadi navigatorkey.currentcontext selalu null di sana. s.of juga butuh context jadi ga bisa dipakai di sana. cara paling beres: lokalisasi di server sebelum notif dikirim. simpan locale tiap user di backend, terus kirim title sama body yang sudah diterjemahkan. fcm juga dukung title loc key sama body loc key kalau mau pakai string resource native. kalau tetap mau lokalisasi di dalam handler, jangan pakai context sama sekali. baca locale dari sharedpreferences, terus ambil stringnya dari map biasa atau file json yang kamu load manual di isolate itu. intinya handler cuma butuh locale string sama tabel terjemahan, bukan context. imo opsi server side paling aman, btw handler background juga bisa dipanggil pas aplikasi terminated total dan di sana ga ada apa apa selain isolate kosong. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Please help me. How to get context to localize notification in Application, if app - terminated
I try "GlobalKey" but navigatorKey.currentContext - always null;
All reactions