-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: timeout for beacon notifications
- Loading branch information
Showing
11 changed files
with
197 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+3.22 KB
(130%)
NearBee/NearBeeResources.bundle/NearBeeModel.momd/Model 8.mom
Binary file not shown.
Binary file modified
BIN
+664 Bytes
(100%)
NearBee/NearBeeResources.bundle/NearBeeModel.momd/Model 8.omo
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NearBee/NearBeeResources.bundle/NearBeeModel.momd/VersionInfo.plist
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NearBee/NearBeeResources.bundle/_CodeSignature/CodeDirectory
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NearBee/NearBeeResources.bundle/_CodeSignature/CodeRequirements-1
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>co.nearbee.api_key</key> | ||
<string>e62435a78e67ec98bba3b879ba00448650032557</string> | ||
<key>co.nearbee.organization_id</key> | ||
<string>720</string> | ||
<key>NSBluetoothAlwaysUsageDescription</key> | ||
<string>To scan for beacons around you</string> | ||
<key>NSBluetoothPeripheralUsageDescription</key> | ||
<string>To scan for beacons around you</string> | ||
<key>NSLocationAlwaysUsageDescription</key> | ||
<string>To scan for beacons around you</string> | ||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key> | ||
<string>To monitor and display notifications for beacons in background</string> | ||
<key>NSLocationWhenInUseUsageDescription</key> | ||
<string>To detect beacons around you</string> | ||
<key>UIBackgroundModes</key> | ||
<array> | ||
<string>bluetooth-central</string> | ||
</array> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UILaunchStoryboardName</key> | ||
<string>LaunchScreen</string> | ||
<key>UIMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// | ||
// ViewController.swift | ||
// SampleApp | ||
// | ||
// Created by Sachin Vas on 31/10/18. | ||
// Copyright © 2018 Amit Prabhu. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import NearBee | ||
import CoreData | ||
import UserNotifications | ||
import CoreLocation | ||
import Imaginary | ||
|
||
class ViewController: UITableViewController { | ||
|
||
var MY_TOKEN = "e62435a78e67ec98bba3b879ba00448650032557" // warning: Make sure to replace this | ||
var MY_ORGANIZATION = 720 // warning: Make sure to replace this | ||
|
||
var locationManager = CLLocationManager() | ||
|
||
var nearBee: NearBee! | ||
|
||
var viewBeacons:[NearBeeBeacon] = [] | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
locationManager.requestAlwaysAuthorization() | ||
UNUserNotificationCenter.current().delegate = self | ||
|
||
nearBee = NearBee.initNearBee() | ||
nearBee.delegate = self | ||
nearBee.enableBackgroundNotification(true) | ||
nearBee.startScanning() | ||
} | ||
|
||
override func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
nearBee.delegate = self | ||
} | ||
} | ||
|
||
extension ViewController { | ||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
tableView.deselectRow(at: indexPath, animated: true) | ||
|
||
guard viewBeacons.count > indexPath.row else { | ||
return | ||
} | ||
|
||
let beacon = viewBeacons[indexPath.row] | ||
|
||
guard let eddystoneURL = beacon.getBestAvailableAttachment()?.getURL() else { | ||
return | ||
} | ||
|
||
nearBee.displayContentOf(eddystoneURL) | ||
} | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 1 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return viewBeacons.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
guard let cell = tableView.dequeueReusableCell(withIdentifier: PhysicalWebTableViewCell.cellIdentifier, for: indexPath) as? PhysicalWebTableViewCell, viewBeacons.count > indexPath.row else { | ||
fatalError("Unexpected Index Path") | ||
} | ||
|
||
let beacon = viewBeacons[indexPath.row] | ||
|
||
// Configure Cell | ||
cell.configureCell(beacon: beacon) | ||
|
||
return cell | ||
} | ||
|
||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
if let destination = segue.destination as? GeoFenceViewController { | ||
destination.nearBee = nearBee | ||
} | ||
} | ||
} | ||
|
||
extension ViewController: NearBeeDelegate { | ||
func didFindBeacons(_ beacons: [NearBeeBeacon]) { | ||
let filteredBeacons = beacons.filter { !viewBeacons.contains($0) } | ||
viewBeacons.append(contentsOf: filteredBeacons) | ||
tableView.reloadData() | ||
} | ||
|
||
func didLoseBeacons(_ beacons: [NearBeeBeacon]) { | ||
let filteredBeacons = beacons.filter { !viewBeacons.contains($0) } | ||
viewBeacons.append(contentsOf: filteredBeacons) | ||
tableView.reloadData() | ||
} | ||
|
||
func didUpdateBeacons(_ beacons: [NearBeeBeacon]) { | ||
viewBeacons = viewBeacons.filter { !beacons.contains($0) } | ||
tableView.reloadData() | ||
} | ||
|
||
func didThrowError(_ error: Error) { | ||
viewBeacons = [] | ||
tableView.reloadData() | ||
} | ||
|
||
func didUpdateState(_ state: NearBeeState) { | ||
|
||
} | ||
} | ||
|
||
extension ViewController: UNUserNotificationCenterDelegate { | ||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | ||
let _ = nearBee.checkAndProcessNearbyNotification(response.notification) | ||
completionHandler() | ||
} | ||
} |