Commit b3044eb
authored
Email (#336)
* Email SDK Changes
• Begins to add support for email in the iOS SDK
* Multi-Requests
• Changed the SDK so that for certain HTTP requests (ie. registering a user or sending location), the SDK will send two HTTP requests (separate for Push user ID and Email user ID).
• The method to execute multiple HTTP requests will wait until both finish to trigger a callback. Each request is passed in with a key string. The callback returns key/value pairs where the key is associated with the same key.
• Added tests covering the additional functionality
* Email Logout
• Included app_id as a parameter for the email logout request
• Added a test for email logout
• Fixed an issue where setEmail: did not correctly set the current subscription state email user ID
* Faster Tests
• Got rid of a thread synchronization line that wasn't necessary and slowed down unit tests by nearly 2x.
* Splitting/Refactoring Tests
• Began (but did not finish) the work of splitting up unit tests so that they are no longer all in one giant file/class and are a bit more modular
• Fixed the Create/Edit device REST requests in the application which were using incorrect 'email' vs. 'identifier' parameter banes
* Re-Attempt Failed Network Requests
• This implements a system so that the SDK will reattempt failed network requests under two possible situations:
1. The HTTP status code is 500+, indicating a server error.
2. The HTTP status code is 0, which in iOS indicates no internet connection
• The re-attempt is only made one time, after waiting 15 seconds.
• The success/fail callbacks are not called until the re-attempt is made. If the second attempt fails, the failure callback is called.
* Fix HTTP Request Re-Attempt Time Definitions
• The re-attempt define statements were incorrect due to debugging, fixed them to be the correct values.
* Multiple Re-Attempts
• Changes the SDK so that multiple re-attempts can be made for failed HTTP requests
• Currently, all failed requests (HTTP code 500+) will be attempted 3 times total.
* OneSignal Email SDK Feature
• Built out most of the Email feature for the SDK
• Improved the failed HTTP request re-attempt code to be a bit more readable
• Put a lot of commonly used strings into a single CommonDefines header file
• Made it so that calls to `setEmail:` will be delayed under two conditions:
1. The player_id is not set, meaning `registerUserInternal()` has not yet finished
2. No email_auth_code was passed in as a parameter to `setEmail:` and the GetIOSParams request has not yet finished.
* Fix Tests
• Fixed some issues that broke unit tests due to email.
• Fixed an issue that added an extra / to the Create Device endpoint path.
* OneSignal SDK + Email
• Added convenience methods to set/logout/etc. from email without completion blocks
• Added another test to cover unauthenticated email
• Fixed some errors with tests
• Changed verbose logging with HTTP requests to log HTTP parameters as pretty-printed JSON for easier debugging with rest clients
• Persists the email_auth_token and email address in NSUserDefaults for use to authenticate in future sessions
• This commit now correctly sends in the email_auth_hash in the correct HTTP requests (send location, send tags, etc)
• The iOS Params file is now downloaded at launch in all cases (since it now effects email)
* Email Fixes
• Made some changes to parameter names for a few endpoints to match what the backend requires
• The backend needs the client to call UpdateDeviceToken even when the user just receives a new email player_id. Added this HTTP request in the setEmail: method.
• Adjusted unit tests to account for the fact that all successful calls to setEmail: will end with a call to UpdateDeviceToken in one way or another
• Added some more checks to the unit tests for Email to ensure it is correctly setting the email and also logs out correctly
• Adjusted the dev app to include an email text field and Set Email + Logout Email buttons to make testing easier.
* Add Carrier Name
• Added "carrier" as a parameter on registration. Uses reflection to access the Core Telephony framework (if available) and uses it to attach the carrier name to the body of the request.
• Fixes an issue with unauthenticated email users where some requests (on_session, update location, etc) weren't being called for Email
• Added emailUserId and emailAddress as parameters in the dictionary & string representations of OSSubscriptionState
* Fixed Tests
• Changed the OSSubscriptionState `description` property to include Email & Email player id in the previous commit.
• This broke a test checking the `description` property.
• Removed this description value as it seems somewhat superfluous to test.
* Email Callbacks on Main Thread
• Because some developers will probably make UI adjustments when the completion block for setEmail() is called, I have changed the SDK to always call the success/fail completion blocks on the main thread.
* Add Email to Swift Demo
• Adds Email functionality to the Swift demo project, both the ability to setUnauthenticatedEmail() and logoutEmail()
• Fixes some minor compiler warnings due to optional string variables
• Adds warning to the syncEmail() method in the SDK so that it will print a warning if the email is invalid or nil. Otherwise developers may not notice that the email isn't actually getting synced since no error is returned.
* Adds Invalid Email Test
• Checks to make sure that the SDK rejects invalid emails.
* Add require_email_auth tests
• Added tests to ensure the SDK correctly handles the require_email_auth parameter from iOS params
• If require_email_auth == true, the SDK should reject attempts to use `setUnauthenticatedEmail:`
* Streamline Email Tests
• Puts commonly used email test setup into its own method to avoid duplication
• Adds more conditions to the testRequiresEmailAuth: test
* Remove Hardcoded URL's
• Unit tests used hardcoded URL's for checking HTTP request correctness
• Unit tests now build use the same compiler definition to get the server URL & api version as the SDK does.
• Moved the URL & API version definitions into the Common Definitions header file
* Split Email & Subscription Observer
• Removed email-related properties and functionality from OSSubscriptionState and created a separate Email Subscription Observer (OSEmailSubscription)
• Created a new protocol so that developers can add email observers and get updated whenever the values change.
• Added tests for the new email subscription observer
• Fixed an issue where a change in the email player ID in response to registration/device token update would not have been reflected in the SDK
* Track In-App Purchase Safety Check
• Checks to make sure the SKPaymentQueue class responds to the canMakePayments() selector before calling it.
• Cleans up email-related OneSignal.h header declarations, adds some comments, and moves unnecessary typedefs to a more appropriate header file (OneSignalClient.h)
* Update Server URL
• Mistakenly committed staging server as the OneSignal server URL in common defines
* Add Email to OneSignal.getPermissionSubscriptionState()
• Adds an Email subscription state property to the result of getPermissionSubscriptionState()
• This allows developers to ask if the user is subscribed to onesignal email.
* Avoid Duplicate Requests
• If setEmail() is called, and then gets called later on with the same parameters (same email address), there is no need to perform another HTTP request
• This was implemented in a previous commit but would have failed if using email in an unauthenticated state, since emailAuthToken is nil.
• The NSString comparison would return false if one/both strings were nil
• Fixed it so that if both strings are nil (unauthenticated state), it will correctly identify it as a duplicate request if the emails match (existing email and email passed in as parameter to setEmail())
* Fix iOS Params Request
• The SDK was calling a method to download the iOS parameters file whenever init() was called on the OneSignal SDK
• Since some wrapper SDK's will call init() twice, this caused an unnecessary duplicate call to downloadIOSParams
• Resolved by using a static boolean flag to prevent duplicate calls
• Adjusted some of the tests to reflect this change.
* Change setUnauthenticatedEmail
• We've decided to rename setUnauthenticatedEmail: to setEmail: (but without an emailAuthToken parameter)
* Null Email Auth Token
• Some wrapper SDK's pass in NSNull instead of nil, which caused an issue with the setEmail: method.
• Added a check for this condition.
* Add (unfinished) test for on_focus
• Check to make sure the SDK is correctly sending on_focus events for both email and push player ID's
* Add Email Tests
• Adds tests to ensure that:
• The register user request will send out two requests, one for email player ID (if it exists) and one for push
• on_focus events also send out two requests, one for email & push
* Fix Failing Test Build
• CI build appears to be failing for a strange issue on line 805 of OneSignal.m
callbackSet.failureBlock(error);
• Added some parentheses to ensure the correct codepath is being followed.
* Remove Extraneous Log Statements
• Removes extraneous log statements
• Fixes header comments for OSEmailSubscription class
* Update Travis Config
• Travis build is failing due to an 'undeclared identifier' error. However this doesn't appear to be correct, attempting to change Travis yml settings.
• Remove an unnecessary log statement
* Fix Test
• Travis refuses to build, attempt to fix by redefining the `error` variable causing the issue.
* Change Travis Build Scheme
• Travis doesn't appear to have support for running tests targeted at iOS 11.2. Changed config file back to iOS 11.0
* Fix Test Build Issue
• Remove the 'error' variable entirely.
• Travis CI complains this variable is undeclared.....1 parent 94dd9b4 commit b3044eb
File tree
41 files changed
+2483
-508
lines changed- Examples/SwiftExample/OneSignalDemo
- Base.lproj
- iOS_SDK
- OneSignalDevApp/OneSignalDevApp
- Base.lproj
- OneSignalSDK
- OneSignal.xcodeproj
- Source
- UnitTests
- Shadows
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
41 files changed
+2483
-508
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
Lines changed: 65 additions & 16 deletions
Large diffs are not rendered by default.
Lines changed: 104 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
53 | 72 | | |
54 | 73 | | |
55 | 74 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
60 | 79 | | |
61 | 80 | | |
62 | 81 | | |
63 | 82 | | |
64 | 83 | | |
65 | | - | |
66 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
67 | 117 | | |
68 | 118 | | |
69 | 119 | | |
| |||
82 | 132 | | |
83 | 133 | | |
84 | 134 | | |
| 135 | + | |
| 136 | + | |
85 | 137 | | |
86 | 138 | | |
87 | 139 | | |
| |||
93 | 145 | | |
94 | 146 | | |
95 | 147 | | |
| 148 | + | |
| 149 | + | |
96 | 150 | | |
97 | 151 | | |
98 | 152 | | |
| |||
115 | 169 | | |
116 | 170 | | |
117 | 171 | | |
| 172 | + | |
118 | 173 | | |
119 | 174 | | |
120 | 175 | | |
| |||
126 | 181 | | |
127 | 182 | | |
128 | 183 | | |
129 | | - | |
| 184 | + | |
130 | 185 | | |
131 | 186 | | |
132 | 187 | | |
133 | 188 | | |
134 | 189 | | |
135 | 190 | | |
136 | 191 | | |
137 | | - | |
| 192 | + | |
138 | 193 | | |
139 | 194 | | |
140 | 195 | | |
141 | 196 | | |
142 | 197 | | |
143 | 198 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
149 | 216 | | |
150 | 217 | | |
| 218 | + | |
151 | 219 | | |
152 | 220 | | |
153 | 221 | | |
| |||
161 | 229 | | |
162 | 230 | | |
163 | 231 | | |
164 | | - | |
| 232 | + | |
165 | 233 | | |
166 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
167 | 237 | | |
168 | 238 | | |
169 | 239 | | |
170 | 240 | | |
171 | | - | |
172 | | - | |
173 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
174 | 248 | | |
175 | 249 | | |
176 | 250 | | |
| |||
247 | 321 | | |
248 | 322 | | |
249 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
95 | 103 | | |
96 | 104 | | |
97 | 105 | | |
| |||
115 | 123 | | |
116 | 124 | | |
117 | 125 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| |||
0 commit comments