From 926914e3c4f9ab132530c455537eb3e48c4a3068 Mon Sep 17 00:00:00 2001 From: vishnuraghavb Date: Fri, 18 Jun 2021 21:52:36 +0530 Subject: [PATCH] updated fgservice location --- app/services/ForegroundService.js | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/services/ForegroundService.js diff --git a/app/services/ForegroundService.js b/app/services/ForegroundService.js new file mode 100644 index 00000000..800bf5c7 --- /dev/null +++ b/app/services/ForegroundService.js @@ -0,0 +1,37 @@ +import { TimerNotif } from '../shared/utils' +const superProto = android.app.Service.prototype + +android.app.Service.extend('com.tns.ForegroundService', { + onStartCommand: function(intent, flags, startId) { + superProto.onStartCommand.call(this, intent, flags, startId) + return android.app.Service.START_STICKY + }, + onCreate: function() { + superProto.onCreate.call(this) + this.startForeground(6, this.getNotification()) + }, + onBind: function(intent) { + return superProto.onBind.call(this, intent) + }, + onUnbind: function(intent) { + return superProto.onUnbind.call(this, intent) + }, + onDestroy: function() { + this.stopForeground(true) + }, + getNotification: function() { + return TimerNotif.getNotification( + { + bID: 'info', + cID: 'cti', + cName: 'Cooking Timer info', + description: `0 ongoing, 0 paused`, + nID: 6, + priority: -2, + sound: null, + title: 'EnRecipes is running', + }, + this.getApplicationContext() + ) + }, +})