Skip to content

Commit

Permalink
Fix: timeout for beacon notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Souro7 committed Aug 14, 2020
1 parent 57df232 commit 0c408a7
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 11 deletions.
2 changes: 1 addition & 1 deletion NearBee.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'NearBee'
s.swift_version = '5.0'
s.version = '0.3.0'
s.version = '0.3.1'
s.summary = 'iOS library for Eddystone beacons'

s.homepage = 'https://github.com/Beaconstac/NearBee-iOS-SDK'
Expand Down
2 changes: 1 addition & 1 deletion NearBee/NearBee-Swift.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,4 @@ typedef SWIFT_ENUM(NSInteger, NearBeeState, closed) {
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop
#pragma clang diagnostic pop
Binary file modified NearBee/NearBeeResources.bundle/NearBeeModel.momd/Model 8.mom
Binary file not shown.
Binary file modified NearBee/NearBeeResources.bundle/NearBeeModel.momd/Model 8.omo
Binary file not shown.
Binary file not shown.
Binary file modified NearBee/NearBeeResources.bundle/_CodeSignature/CodeDirectory
Binary file not shown.
Binary file not shown.
18 changes: 9 additions & 9 deletions NearBee/NearBeeResources.bundle/_CodeSignature/CodeResources
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
</data>
<key>NearBeeModel.momd/Model 8.mom</key>
<data>
VWTw85YRgyKvHzWfHzJJUICSayY=
ubeT80Uea2cTJhh7i8mO4nJW7a0=
</data>
<key>NearBeeModel.momd/Model 8.omo</key>
<data>
Ida8Cb68I3+PDmbJfLqF1cxWcXY=
Jm6sJjnuENUUIXKuRDYbqswW6s0=
</data>
<key>NearBeeModel.momd/Model.mom</key>
<data>
2IG9nvXDnU3VZCS9E7v3uS3enHE=
</data>
<key>NearBeeModel.momd/VersionInfo.plist</key>
<data>
2z8a6yNKSBQD51OLlEdELqZOrpg=
Asdxtn5l15GnYdaJRkXv4KXrMzo=
</data>
</dict>
<key>files2</key>
Expand Down Expand Up @@ -117,22 +117,22 @@
<dict>
<key>hash</key>
<data>
VWTw85YRgyKvHzWfHzJJUICSayY=
ubeT80Uea2cTJhh7i8mO4nJW7a0=
</data>
<key>hash2</key>
<data>
3vvdFFLA4oGl576yRlbTkMTY1fHUrGAZOjghCpylECg=
ABaLOknuCInG7VtNmT1nqcypOUVjzlW+pwUzHgtt4RY=
</data>
</dict>
<key>NearBeeModel.momd/Model 8.omo</key>
<dict>
<key>hash</key>
<data>
Ida8Cb68I3+PDmbJfLqF1cxWcXY=
Jm6sJjnuENUUIXKuRDYbqswW6s0=
</data>
<key>hash2</key>
<data>
rE9U5HgIUnfDPIv5DWWDYElKVEiJF/NU6Ww27p9lOtQ=
TOlKQ792k3D6iVdpvGLl6fpdoFgFkUlN1uagw2rss2Y=
</data>
</dict>
<key>NearBeeModel.momd/Model.mom</key>
Expand All @@ -150,11 +150,11 @@
<dict>
<key>hash</key>
<data>
2z8a6yNKSBQD51OLlEdELqZOrpg=
Asdxtn5l15GnYdaJRkXv4KXrMzo=
</data>
<key>hash2</key>
<data>
b+BCI/YICKyQ7y6eaYcHPQxd9kWK6xoE3Tkmy+VuhZI=
Po8+Uns8OEa0nEyGqAyyFseNTg4Mf5FmibsV7x8aI00=
</data>
</dict>
</dict>
Expand Down
Binary file modified NearBee/libNearBee.a
Binary file not shown.
63 changes: 63 additions & 0 deletions SampleApp/SampleApp/Info.plist
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>
123 changes: 123 additions & 0 deletions SampleApp/SampleApp/ViewController.swift
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()
}
}

0 comments on commit 0c408a7

Please sign in to comment.