小编Dan*_*n_R的帖子

基于地区的本地通知

我目前正在使用"Regions"示例代码:https: //developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.h tml#// apple_ref/doc/uid/DTS40010726-Intro-DontLinkElementID_2

我想更进一步,当用户退出该区域时生成或触发通知(可以同时进入和退出,我不介意,对于初始实现最简单的事情).

我一直在查看CLLocation类参考,位置感知编程指南以及本地和推送通知编程指南.而我正在遭受信息超载.

非常感谢 :)

编辑:我想我可能有一个解决问题的想法:在RegionsViewController实现文件中有这样的:

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region        {
    NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];

    [self updateWithEvent:event];
}
Run Code Online (Sandbox Code Playgroud)

由于我想在用户退出指定区域边界时实现本地通知,我输入了以下内容:

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
    NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];
    [self updateWithEvent:event];
    //implement local notification: 
    UIApplication *app                = [UIApplication sharedApplication];
    UILocalNotification *notification = [[UILocalNotification alloc] init];
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

    if (notification == nil)
        return;

    notification.alertBody = [NSString stringWithFormat:@"Did You Lock Your …
Run Code Online (Sandbox Code Playgroud)

geocoding geolocation geofencing

6
推荐指数
1
解决办法
3137
查看次数

无法在没有 X11 的 $DISPLAY 的情况下自动启动 dbus 守护程序。网豆。Pi作为远程主机

我正在尝试使用我的 NetBeans IDE 运行以下示例代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus.h>
 
int main() {
    DBusConnection *connection = NULL;
    DBusError error;
    char buffer[1024];
 
    dbus_error_init(&error);
    connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
    if (dbus_error_is_set(&error)) {
        fprintf(stderr, "%s", error.message);
        abort();
    }
 
    puts("This is my unique name");
    puts(dbus_bus_get_unique_name(connection));
    fgets(buffer, sizeof(buffer), stdin);
     
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

来自一个优秀的教程: DBUS TUTORIAL USING THE LOW-LEVEL API

我为 SSH 设置了无头 Pi,并安装了 dbus 开发所需的所有库。

但是,在 Netbeans 中运行程序时,我收到以下错误

无法在没有 X11 的 $DISPLAY 的情况下自动启动 dbus 守护程序

/usr/bin/dbus-launch 异常终止并出现以下错误:自动启动错误:X11 初始化失败。

请注意,我在 Netbeans 上的远程主机属性中启用了 X11 转发

我可以看到,如果我自己通过 …

c dbus raspbian netbeans-8 raspberry-pi3

5
推荐指数
2
解决办法
4万
查看次数

如何提高区域边界跨越精度(模拟)(地理围栏)

我把一个应用程序放在一起,当用户离开房子时发出通知.所以我实现了半径为25的区域监控.我遇到的问题是模拟时(iPhone模拟器5.0),我设置了一个自定义位置(home)设置区域边界.然后输入区域边界外的另一个自定义位置,即在街道的尽头.但该应用程序没有注册退出该地区.只有当我设置了家庭位置和地区,然后更改为Apple总部,它会注册并发出通知.在后台模式下,应用切换到重要的位置更改.但是在前台或后台时它有同样的问题.正在寻找的内容,如"提醒"应用程序,是应用程序在退出/离开区域边界后立即发出通知,即走到街道的尽头.我如何使其更准确?

这是我的一些viewcontroller.m文件:

- (void)viewDidLoad {
    [super viewDidLoad];

  // Create empty array to add region events to.
  updateEvents = [[NSMutableArray alloc] initWithCapacity:0];

  // Create location manager with filters set for battery efficiency.
  locationManager = [[CLLocationManager alloc] init];
  locationManager.delegate = self;
  locationManager.distanceFilter = kCLLocationAccuracyBest; //could try KLDistanceFilterNone;
  locationManager.desiredAccuracy = kCLLocationAccuracyBest;

  // Start updating location changes.
          [locationManager startUpdatingLocation];
}

- (void)viewDidAppear:(BOOL)animated {
  // Get all regions being monitored for this application.
  NSArray *regions = [[locationManager monitoredRegions] allObjects];

  // Iterate through the regions and …
Run Code Online (Sandbox Code Playgroud)

location geolocation ios ios-simulator geofencing

2
推荐指数
1
解决办法
5142
查看次数