|
5 | 5 | import XCTest
|
6 | 6 |
|
7 | 7 | import UserNotifications
|
| 8 | +import UniformTypeIdentifiers |
8 | 9 |
|
9 | 10 | @testable import IterableAppExtensions
|
10 | 11 |
|
@@ -62,72 +63,70 @@ class NotificationExtensionSwiftTests: XCTestCase {
|
62 | 63 | wait(for: [condition1], timeout: timeout)
|
63 | 64 | }
|
64 | 65 |
|
65 |
| -// func testPushImageAttachment() { |
66 |
| -// let condition1 = expectation(description: "image attachment didn't function as expected") |
67 |
| -// |
68 |
| -// let content = UNMutableNotificationContent() |
69 |
| -// let messageId = UUID().uuidString |
70 |
| -// |
71 |
| -// content.userInfo = [ |
72 |
| -// "itbl": [ |
73 |
| -// "messageId": messageId, |
74 |
| -// "attachment-url": "https://github.com/Iterable/swift-sdk/raw/master/images/Iterable-Logo.png" |
75 |
| -// ] |
76 |
| -// ] |
77 |
| -// |
78 |
| -// let request = UNNotificationRequest(identifier: "request", content: content, trigger: nil) |
79 |
| -// |
80 |
| -// appExtension.didReceive(request) { content in |
81 |
| -// XCTAssertEqual(content.attachments.count, 1) |
82 |
| -// |
83 |
| -// guard let firstAttachment = content.attachments.first else { |
84 |
| -// XCTFail("attachment doesn't exist") |
85 |
| -// return |
86 |
| -// } |
87 |
| -// |
88 |
| -// XCTAssertNotNil(firstAttachment.url) |
89 |
| -// XCTAssertEqual(firstAttachment.url.scheme, "file") |
90 |
| -// |
91 |
| -// // at some point, fix this to use proper typing through the UniformTypeIdentifiers framework |
92 |
| -// XCTAssertEqual(firstAttachment.type, "public.png") |
93 |
| -// |
94 |
| -// condition1.fulfill() |
95 |
| -// } |
96 |
| -// |
97 |
| -// wait(for: [condition1], timeout: timeout) |
98 |
| -// } |
99 |
| -// |
100 |
| -// func testPushVideoAttachment() { |
101 |
| -// let condition1 = expectation(description: "video attachment didn't function as expected") |
102 |
| -// |
103 |
| -// let content = UNMutableNotificationContent() |
104 |
| -// let messageId = UUID().uuidString |
105 |
| -// |
106 |
| -// content.userInfo = [ |
107 |
| -// "itbl": [ |
108 |
| -// "messageId": messageId, |
109 |
| -// "attachment-url": "https://github.com/Iterable/swift-sdk/raw/master/tests/notification-extension-tests/swirl.mp4" |
110 |
| -// ] |
111 |
| -// ] |
112 |
| -// |
113 |
| -// let request = UNNotificationRequest(identifier: "request", content: content, trigger: nil) |
114 |
| -// |
115 |
| -// appExtension.didReceive(request) { content in |
116 |
| -// guard let firstAttachment = content.attachments.first else { |
117 |
| -// XCTFail("attachment doesn't exist") |
118 |
| -// return |
119 |
| -// } |
120 |
| -// |
121 |
| -// XCTAssertNotNil(firstAttachment.url) |
122 |
| -// XCTAssertEqual(firstAttachment.url.scheme, "file") |
123 |
| -// |
124 |
| -// // at some point, fix this to use proper typing through the UniformTypeIdentifiers framework |
125 |
| -// XCTAssertEqual(firstAttachment.type, "public.mpeg-4") |
126 |
| -// |
127 |
| -// condition1.fulfill() |
128 |
| -// } |
129 |
| -// |
130 |
| -// wait(for: [condition1], timeout: timeout) |
131 |
| -// } |
132 |
| -} |
| 66 | + @available(iOS 14.0, *) |
| 67 | + func testPushImageAttachment() { |
| 68 | + let condition1 = expectation(description: "image attachment didn't function as expected") |
| 69 | + |
| 70 | + let content = UNMutableNotificationContent() |
| 71 | + let messageId = UUID().uuidString |
| 72 | + |
| 73 | + content.userInfo = [ |
| 74 | + "itbl": [ |
| 75 | + "messageId": messageId, |
| 76 | + "attachment-url": "https://github.com/Iterable/swift-sdk/raw/master/images/Iterable-Logo.png" |
| 77 | + ] |
| 78 | + ] |
| 79 | + |
| 80 | + let request = UNNotificationRequest(identifier: "request", content: content, trigger: nil) |
133 | 81 |
|
| 82 | + appExtension.didReceive(request) { content in |
| 83 | + XCTAssertEqual(content.attachments.count, 1) |
| 84 | + |
| 85 | + guard let firstAttachment = content.attachments.first else { |
| 86 | + XCTFail("attachment doesn't exist") |
| 87 | + return |
| 88 | + } |
| 89 | + |
| 90 | + XCTAssertNotNil(firstAttachment.url) |
| 91 | + XCTAssertEqual(firstAttachment.url.scheme, "file") |
| 92 | + XCTAssertEqual(firstAttachment.type, UTType.png.identifier) |
| 93 | + |
| 94 | + condition1.fulfill() |
| 95 | + } |
| 96 | + |
| 97 | + wait(for: [condition1], timeout: timeout) |
| 98 | + } |
| 99 | + |
| 100 | + @available(iOS 14.0, *) |
| 101 | + func testPushVideoAttachment() { |
| 102 | + let condition1 = expectation(description: "video attachment didn't function as expected") |
| 103 | + |
| 104 | + let content = UNMutableNotificationContent() |
| 105 | + let messageId = UUID().uuidString |
| 106 | + |
| 107 | + content.userInfo = [ |
| 108 | + "itbl": [ |
| 109 | + "messageId": messageId, |
| 110 | + "attachment-url": "https://github.com/Iterable/swift-sdk/raw/master/tests/notification-extension-tests/swirl.mp4" |
| 111 | + ] |
| 112 | + ] |
| 113 | + |
| 114 | + let request = UNNotificationRequest(identifier: "request", content: content, trigger: nil) |
| 115 | + |
| 116 | + appExtension.didReceive(request) { content in |
| 117 | + guard let firstAttachment = content.attachments.first else { |
| 118 | + XCTFail("attachment doesn't exist") |
| 119 | + return |
| 120 | + } |
| 121 | + |
| 122 | + XCTAssertNotNil(firstAttachment.url) |
| 123 | + XCTAssertEqual(firstAttachment.url.scheme, "file") |
| 124 | + |
| 125 | + XCTAssertEqual(firstAttachment.type, UTType.mpeg4Movie.identifier) |
| 126 | + |
| 127 | + condition1.fulfill() |
| 128 | + } |
| 129 | + |
| 130 | + wait(for: [condition1], timeout: timeout) |
| 131 | + } |
| 132 | +} |
0 commit comments