Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into next
Browse files Browse the repository at this point in the history
# Conflicts:
#	Airship.podspec
#	Airship/Airship.xcodeproj/project.pbxproj
#	Airship/AirshipConfig.xcconfig
#	Airship/AirshipCore/Source/AirshipVersion.swift
#	Airship/AirshipCore/Source/NativeBridge.swift
#	Airship/AirshipCore/Source/Push.swift
#	Airship/AirshipCore/Tests/PushTest.swift
#	AirshipContentExtension.podspec
#	AirshipDebug.podspec
#	AirshipExtensions.podspec
#	AirshipServiceExtension.podspec
  • Loading branch information
rlepinski committed Nov 29, 2022
2 parents cd0da54 + 24c4ac5 commit 0a8caad
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 14 deletions.
10 changes: 9 additions & 1 deletion Airship/AirshipCore/Source/AirshipJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ public enum AirshipJSON: Codable, Equatable {
return .string(string)
}

if let number = value as? NSNumber {
if (CFBooleanGetTypeID() == CFGetTypeID(number)) {
return .bool(number.boolValue)
} else {
return .number(number.doubleValue)
}
}

if let bool = value as? Bool {
return .bool(bool)
}

if let number = value as? Double {
return .number(number)
}
Expand Down
8 changes: 2 additions & 6 deletions Airship/AirshipCore/Source/NativeBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@
/// NativeBridge initializer.
@objc
public convenience override init() {
let actionHandler: NativeBridgeActionHandlerProtocol =
NativeBridgeActionHandler.init()
let javaScriptEnvironment: JavaScriptEnvironmentProtocol =
JavaScriptEnvironment.init()
self.init(
actionHandler: actionHandler,
actionHandler: NativeBridgeActionHandler(),
javaScriptEnvironmentFactoryBlock: {
return javaScriptEnvironment
return JavaScriptEnvironment()
}
)
}
Expand Down
7 changes: 4 additions & 3 deletions Airship/AirshipCore/Source/Push.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,12 @@ public class Push: NSObject, Component, PushProtocol {
#endif
self.notificationCenter.addObserver(
self,
selector: #selector(applicationDidTransitionToForeground),
name: AppStateTracker.didTransitionToForeground,
selector: #selector(applicationDidBecomeActive),
name: AppStateTracker.didBecomeActiveNotification,
object: nil
)


self.notificationCenter.addObserver(
self,
selector: #selector(applicationDidEnterBackground),
Expand Down Expand Up @@ -1032,7 +1033,7 @@ public class Push: NSObject, Component, PushProtocol {
}

@objc
private func applicationDidTransitionToForeground() {
private func applicationDidBecomeActive() {
if self.privacyManager.isEnabled(.push) {
self.updateAuthorizedNotificationTypes()
}
Expand Down
12 changes: 12 additions & 0 deletions Airship/AirshipCore/Tests/AirshipJSONTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ final class AirshipJSONTest: XCTestCase {
XCTAssertEqual(.number(100.0), try AirshipJSON.wrap(100.0))
XCTAssertEqual(.number(99.0), try AirshipJSON.wrap(99))
XCTAssertEqual(.number(33.0), try AirshipJSON.wrap(UInt(33)))
XCTAssertEqual(.number(1), try AirshipJSON.wrap(1))
XCTAssertEqual(.number(0), try AirshipJSON.wrap(0))

XCTAssertEqual(.string("hello"), try AirshipJSON.wrap("hello"))
XCTAssertEqual(.bool(true), try AirshipJSON.wrap(true))
XCTAssertEqual(.bool(false), try AirshipJSON.wrap(false))
XCTAssertEqual(.null, try AirshipJSON.wrap(nil))
}

func testWrapNSNumber() throws {
XCTAssertEqual(.number(100.0), try AirshipJSON.wrap(NSNumber(100)))
XCTAssertEqual(.number(99.0), try AirshipJSON.wrap(NSNumber(99.0)))
XCTAssertEqual(.number(33.0), try AirshipJSON.wrap(NSNumber(33.0)))
XCTAssertEqual(.number(1), try AirshipJSON.wrap(NSNumber(1)))
XCTAssertEqual(.number(0), try AirshipJSON.wrap(NSNumber(0)))
XCTAssertEqual(.bool(true), try AirshipJSON.wrap(NSNumber(true)))
XCTAssertEqual(.bool(false), try AirshipJSON.wrap(NSNumber(false)))
}

func testWrapArray() throws {
let array: [Any?] = [
"hello",
Expand Down
11 changes: 7 additions & 4 deletions Airship/AirshipCore/Tests/PushTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -657,17 +657,18 @@ class PushTest: XCTestCase {
XCTAssertEqual(0, self.badger.applicationIconBadgeNumber)
}

func testForegroundChecksRegistration() {
func testActiveChecksRegistration() {
let updated = self.expectation(description: "Updated")
self.notificationRegistrar.onCheckStatus = { completion in
completion(.authorized, [.alert])
updated.fulfill()
}

self.notificationCenter.post(
name: AppStateTracker.didTransitionToForeground,
name: AppStateTracker.didBecomeActiveNotification,
object: nil
)

self.wait(for: [updated], timeout: 1)

XCTAssertEqual(.authorized, self.push.authorizationStatus)
Expand All @@ -683,9 +684,10 @@ class PushTest: XCTestCase {
}

self.notificationCenter.post(
name: AppStateTracker.didTransitionToForeground,
name: AppStateTracker.didBecomeActiveNotification,
object: nil
)

self.wait(for: [updated], timeout: 1)

XCTAssertTrue(self.channel.updateRegistrationCalled)
Expand Down Expand Up @@ -827,9 +829,10 @@ class PushTest: XCTestCase {
}

self.notificationCenter.post(
name: AppStateTracker.didTransitionToForeground,
name: AppStateTracker.didBecomeActiveNotification,
object: nil
)

self.wait(for: [called], timeout: 1)
}

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@

[Migration Guides](https://github.com/urbanairship/ios-library/tree/main/Documentation/Migration)

## Version 16.10.4 November 22, 2022
Patch release that fixes a regression with Scenes and Surveys next page button enablement. Apps on 16.10.1-16.10.3 that use Scenes & Surveys should update.

### Changes
- Fix pager button enablement

## Version 16.10.3 November 15, 2022
Patch release that fixes checking for notification opt-in when disabling the config option requestAuthorizationToUseNotifications.

### Changes
- Check for notification opt-in on active, not just transition to foreground.

## Version 16.10.2 November 7, 2022
Patch release to fix a delay when creating the Airship channel on first run. Apps that are using 16.10.1 or `requireInitialRemoteConfigEnabled` config should update.

Expand Down

0 comments on commit 0a8caad

Please sign in to comment.