코드 도구 응용 프로그램에 https://github.com/katzer/cordova-plugin-background-mode과 https://github.com/katzer/cordova-plugin-local-notifications을 설치했습니다.Cordova 응용 프로그램 모니터링 evimings 앱이 죽은 상태 인 동안 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 [General -> Capabilities]의 설정을 변경했습니다.
앱이 배경에 있어도 앱이 죽으면 멈추지 만 살해되지 않아도 필요한 앱입니다. 앱이 오프라인 상태 일 때 사용자가 앱을 켤 수 있도록 신호가 범위 내에 있다는 알림을 보내려고합니다.