Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/no-connection…
Browse files Browse the repository at this point in the history
…-serial

# Conflicts:
#	Source/ARTRealtimeChannel.m
#	Test/Tests/ARTDefaultTests.swift
  • Loading branch information
maratal committed Aug 2, 2023
2 parents d247e1e + 273277e commit e7b0689
Show file tree
Hide file tree
Showing 53 changed files with 1,929 additions and 289 deletions.
2 changes: 1 addition & 1 deletion Ably.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Ably"
s.version = `Scripts/get-version.sh`
s.version = '1.2.21-beta.1'
s.summary = "iOS, tvOS and macOS Objective-C and Swift client for Ably"
s.description = <<-DESC
iOS, tvOS and macOS Objective-C and Swift client library for ably.com, the realtime messaging service.
Expand Down
80 changes: 56 additions & 24 deletions Ably.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## [1.2.21-beta.1](https://github.com/ably/ably-cocoa/tree/1.2.21-beta.1)

[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.2.20...1.2.21-beta.1)

**Implemented features:**

- A preview of an implementation of the location pushes [\#1771](https://github.com/ably/ably-cocoa/issues/1771)
- Incremental backoff and jitter [\#1431](https://github.com/ably/ably-cocoa/issues/1431)
- Handle os connectivity event while CONNECTING [\#1626](https://github.com/ably/ably-cocoa/issues/1626)

**Closed issues:**

- Compiler warning "Non-portable path to file..." [\#1757](https://github.com/ably/ably-cocoa/issues/1757)
- App crash and dyld error message "AblyDeltaCodec cannot be loaded, image not found" [\#1183](https://github.com/ably/ably-cocoa/issues/1183)

## [1.2.20](https://github.com/ably/ably-cocoa/tree/1.2.20)

[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.2.19...1.2.20)
Expand Down
10 changes: 10 additions & 0 deletions Examples/AblyPush/AblyLocationPush/AblyLocationPush.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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>com.apple.security.application-groups</key>
<array>
<string>group.$(CFBundleIdentifier)</string>
</array>
</dict>
</plist>
13 changes: 13 additions & 0 deletions Examples/AblyPush/AblyLocationPush/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.location.push.service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).LocationPushService</string>
</dict>
</dict>
</plist>
83 changes: 83 additions & 0 deletions Examples/AblyPush/AblyLocationPush/LocationPushService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import CoreLocation

struct LocationPushEvent: Codable {
var id: UUID
var receivedAt: Date
var jsonPayload: Data
}

class LocationPushService: NSObject, CLLocationPushServiceExtension, CLLocationManagerDelegate {

var completion: (() -> Void)?
var locationManager: CLLocationManager!

func didReceiveLocationPushPayload(_ payload: [String : Any], completion: @escaping () -> Void) {
recordPushPayload(payload)

self.completion = completion
self.locationManager = CLLocationManager()
self.locationManager.delegate = self
self.locationManager.requestLocation()
}

/**
* This method is used to exchange information between the app and the extension.
* This gives a user, who testing location pushes without access to the debug console, to see actual notifications in the `LocationPushEventsView`.
*/
private func recordPushPayload(_ payload: [String : Any]) {
guard let sharedContainerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.\(Bundle.main.bundleIdentifier!)") else {
return print("App Groups were not configured properly. Check 'Signing & Capabilities' tab of the project settings.")
}

let dataFileURL = sharedContainerURL.appendingPathComponent("dataFile")

let readCoordinator = NSFileCoordinator()
var readError: NSError? = nil
var data: Data? = nil
readCoordinator.coordinate(readingItemAt: dataFileURL, error: &readError) { url in
if FileManager.default.fileExists(atPath: url.path) {
data = FileManager.default.contents(atPath: url.path)!
}
}

guard readError == nil else {
return
}

let event = LocationPushEvent(id: UUID(), receivedAt: Date(), jsonPayload: try! JSONSerialization.data(withJSONObject: payload))
var events: [LocationPushEvent] = []

if let data {
events = try! JSONDecoder().decode([LocationPushEvent].self, from: data)
events.append(event)
} else {
events = [event]
}

let newData = try! JSONEncoder().encode(events)

let writeCoordinator = NSFileCoordinator()
var writeError: NSError? = nil
writeCoordinator.coordinate(writingItemAt: dataFileURL, error: &writeError) { url in
try! newData.write(to: url)
}
}

func serviceExtensionWillTerminate() {
// Called just before the extension will be terminated by the system.
self.completion?()
}

// MARK: - CLLocationManagerDelegate methods

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// Process the location(s) as needed
print("Locations received: \(locations)")
self.completion?()
}

func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Location manager failed: \(error)")
self.completion?()
}
}
Loading

0 comments on commit e7b0689

Please sign in to comment.