コードバスアプリケーションにhttps://github.com/katzer/cordova-plugin-background-modeとhttps://github.com/katzer/cordova-plugin-local-notificationsをインストールしました。Cordovaアプリケーションのモニタリングのエビデンスアプリが死んでいる状態でのEstimote/iBeacon IOS
私は、ビーコンが検出され、地域にいると通知を送信して、バックグラウンドでビーコンを監視しようとしています。
2つのプラグインを使用すると、ユーザーがアプリの画面を終了してもアプリが正常に機能しますが、アプリがまだオンになっていますが、ユーザーがプロセスを完全に終了したときは機能しません。
これは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]の設定も変更しました。
アプリがバックグラウンドであっても、アプリが殺されると停止しても殺されない場合でも必要なことをアプリは行います。私は、ビーコンが範囲内にあるので、ユーザーがアプリをオンにできるように、アプリがオフラインであるときに通知を送信しようとしています。