0
我在iOS開發中很新手,幾個星期後我開始與iBeacon合作。我目前正在開發一款應用程序,可在用戶進入信標範圍(例如商店區域)時向用戶提供優惠券。這張優惠券不得不一次交付一次,但用戶很可能會留在信標範圍內,即使交付完成後,我也需要應用程序暫停「收聽」特定信標一段固定的時間,讓我們說30分鐘。如何在範圍內暫停信標通知?
這是我實現locationManager:didRangeBeacons:inRegion:
的:
- (void)locationManager:(CLLocationManager *)manager
didRangeBeacons:(NSArray *)beacons
inRegion:(CLBeaconRegion *)region {
if (foundBeacons.count == 0) {
for (CLBeacon *filterBeacon in beacons) {
// If a beacon is located near the device and its major and minor values are equal to some constants
if (((filterBeacon.proximity == CLProximityImmediate) || (filterBeacon.proximity == CLProximityNear)) && ([filterBeacon.major isEqualToNumber:[NSNumber numberWithInt:MAJOR]]) && ([filterBeacon.minor isEqualToNumber:[NSNumber numberWithInt:MINOR]]))
// Registers the beacon to the list of recognized beacons
[foundBeacons addObject:filterBeacon];
}
}
// Did some beacon get found?
if (foundBeacons.count > 0) {
// Takes first beacon of the list
beacon = [foundBeacons firstObject];
if (([beacon.major isEqualToNumber:[NSNumber numberWithInt:MAJOR]]) && ([beacon.minor isEqualToNumber:[NSNumber numberWithInt:MINOR]])) {
// Plays beep sound
AudioServicesPlaySystemSound(soundFileObject);
if (self.delegate) {
// Performs actions related to the beacon (i.e. delivers a coupon)
[self.delegate didFoundBeacon:self];
}
self.locationManager = nil;
}
[foundBeacons removeObjectAtIndex:0];
beacon = nil;
}
}
我如何可以添加一些自拍或使應用程序忽略了,而標相關的東西嗎?