我在我的cordova应用程序中安装了https://github.com/katzer/cordova-plugin-background-mode和https://github.com/katzer/cordova-plugin-local-notifications。科尔多瓦应用程序监控在应用程序处于死亡状态时显示Estimote/iBeacon IOS
我试图在我的应用程序关闭时监视背景中的信标,并且一旦检测到信标并且处于区域中时发送通知。
使用这两个插件,当用户退出应用程序屏幕但应用程序仍然打开时,应用程序成功运行,但用户完全终止进程时不起作用。
这可以单独使用Javascript来完成,还是需要修改AppDelegate.m中的代码?
我已经试过这使用下面的代码:
#import "AppDelegate.h"
#import "MainViewController.h"
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate()
@property (nonatomic, strong) CLLocationManager *locationManager;
@property(nonatomic, assign) BOOL notifyEntryStateOnDisplay;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.viewController = [[MainViewController alloc] init];
self.locationManager = [[CLLocationManager alloc] init];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{
UILocalNotification *notification = [[UILocalNotification alloc] init];
NSLog(@"BLUETOOTH");
if(state == CLRegionStateInside)
{
notification.alertBody = [NSString stringWithFormat:@"You are inside region %@", region.identifier];
}
else if(state == CLRegionStateOutside)
{
notification.alertBody = [NSString stringWithFormat:@"You are outside region %@", region.identifier];
}
else
{
return;
}
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
@end
虽然应用程序不启动。我还更改了我的xCode [常规 - >功能]中的设置,以便后台模式和推送通知处于打开状态。
该应用程序做它所需要的,即使在后台,并没有杀死,尽管一旦应用程序被杀害停止。我试图在应用处于离线状态时发送通知,指示信标处于范围内,以便用户可以打开应用。