This module tries to solve this issue
To use your module locally inside an app you can copy the zip file into the app root folder and compile your app.
The file will automatically be extracted and copied into the correct modules/
folder.
If you want to use your module globally in all your apps you have to do the following:
Copy the distribution zip file into the ~/Library/Application Support/Titanium
folder
Copy the distribution zip file into the ~/.titanium
folder
Register your module with your application by editing tiapp.xml
and adding your module.
Example:
<modules>
<module platform="android">de.appwerft.watchdog</module>
</modules>
<receiver android:name="de.appwerft.watchdog.Watchdog"/>
When you run your project, the compiler will combine your module along with its dependencies and assets into the application.
import SleepDeprivation from 'de.appwerft.watchdog';
SleepDeprivation.start({
interval : 10*1000*60, // ms
debug : true,
exact : false,
startdelay : 0
});
// and optional
SleepDeprivation.stop();
You can use start()
without parameters. In this case it uses the default parameters (10 min, debuging on, inexact, immediately)
function requestIgnoreBatteryOptimizations() {
if (Ti.Platform.Android.API_LEVEL >= 23) {
const intent = Ti.Android.createIntent({
action : "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",
data : "package:" + Ti.App.Android.launchIntent.packageName,
});
Ti.Android.currentActivity.startActivity(intent);
Ti.App.Properties.setBool('IgnoreBatteryOptimizations', true);
}
}
- some manufactures (Samsung Huawei, Nokia) ignore this white list.
- this intent has no result
More: here