Leo*_*Cai 40 background cordova
我的意思是在完全背景下工作,例如,即使屏幕关闭,应用程序正在运行,并可以发送声音通知.
我的应用用于观看价格变化.价格变化时会发出声音警报.
那么,答案应该是肯定还是否定?谢谢.
Mel*_*ani 47
以下是一些可以帮助您的链接
链接3:GitHub中的BackgroundService插件
更新
Cla*_*ish 28
由于iOS 7提供了另一种可能的解决方案,我将为iOS 7及其他用户提供额外的答案.
新的背景提取功能可以定期更新后台应用的内容.提取的时间间隔不能由用户设置,而是由iOS根据其用户的统计信息(应用程序使用情况等)设置.
可以通过插件使用PhoneGap/Cordova访问这一新功能 - 幸运的是,已经开发了一个提供此访问权限的插件.您可以将它安装到您的Cordova项目中
cordova plugin add https://github.com/christocracy/cordova-plugin-background-fetch.git
Run Code Online (Sandbox Code Playgroud)
与提供对iOS本地通知的访问的插件相结合,这可以产生奇迹.还开发了这样的插件,例如这个插件.通过以下方式将其安装到Cordova项目中
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
Run Code Online (Sandbox Code Playgroud)
这些插件现在可以组合在您的javascript代码中,以执行后台活动:
function onDeviceReady() {
var Fetcher = window.plugins.backgroundFetch;
// Your background-fetch handler.
var fetchCallback = function() {
console.log('BackgroundFetch initiated');
// perform your ajax request to server here
$.get({
url: '/heartbeat.json',
callback: function(response) {
// process your response and whatnot.
window.plugin.notification.local.add({ message: 'Just fetched!' }); //local notification
Fetcher.finish(); // <-- N.B. You MUST called #finish so that native-side can signal completion of the background-thread to the os.
}
});
}
Fetcher.configure(fetchCallback);
}
Run Code Online (Sandbox Code Playgroud)
此获取插件使用UIApplicationBackgroundFetchIntervalMinimum获取间隔的值,这导致最快的获取周期.
| 归档时间: |
|
| 查看次数: |
64431 次 |
| 最近记录: |