Commit a42a573
authored
Extension Badge Handling (#352)
Extension Badge Handling
• Moves badge increment/decrement logic from the OneSignal backend to the application itself
• This is accomplished using an app extension with an 'app group' to allow communication of data between the host app and it's notification extension service
• This allows the app to maintain a consistent badge count
• Also cleaned up some Firebase code and moved common strings to a definitions file
• Changed the SDK so that it will default to group.{bundle_id}.onesignal as the App Group name if one is not provided in Info.plist
Swizzle setApplicationIconBadgeNumber()
• Swizzles the setApplicationIconBadgeNumber() method so the SDK always has a consistent badge count even if the developer manually sets it.
Add Tests for Badge Handling
• Adds a test to verify the extension badge handling logic works correctly
• Verifies that manually setting the badge number using UIApplication setApplicationIconBadgeNumber() also updates OneSignal SDK's cached badge value
• Verifies that the SDK correctly handles positive and negative (increment and decrement) badge_inc values
Improve Badge Tests
• Modularizes access to NSUserDefaults in regards to badge logic to a single implementation file
• Moves the badge_inc property into the 'os_data' or 'custom' fields in push notification objects
• Extends badge tests to cover more scenarios
• Fixes header copyrights in multiple files1 parent 61393b7 commit a42a573
File tree
20 files changed
+646
-131
lines changed- iOS_SDK/OneSignalSDK
- OneSignal.xcodeproj
- Source
- UnitTests
- Shadows
20 files changed
+646
-131
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| |||
283 | 287 | | |
284 | 288 | | |
285 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
286 | 293 | | |
287 | 294 | | |
288 | 295 | | |
| |||
406 | 413 | | |
407 | 414 | | |
408 | 415 | | |
| 416 | + | |
409 | 417 | | |
410 | 418 | | |
411 | 419 | | |
| |||
452 | 460 | | |
453 | 461 | | |
454 | 462 | | |
| 463 | + | |
| 464 | + | |
455 | 465 | | |
456 | 466 | | |
457 | 467 | | |
| |||
731 | 741 | | |
732 | 742 | | |
733 | 743 | | |
| 744 | + | |
734 | 745 | | |
735 | 746 | | |
736 | 747 | | |
| |||
768 | 779 | | |
769 | 780 | | |
770 | 781 | | |
| 782 | + | |
771 | 783 | | |
772 | 784 | | |
773 | 785 | | |
| |||
785 | 797 | | |
786 | 798 | | |
787 | 799 | | |
| 800 | + | |
788 | 801 | | |
789 | 802 | | |
790 | 803 | | |
| 804 | + | |
791 | 805 | | |
792 | 806 | | |
793 | 807 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
908 | 910 | | |
909 | 911 | | |
910 | 912 | | |
911 | | - | |
| 913 | + | |
912 | 914 | | |
913 | 915 | | |
914 | 916 | | |
915 | 917 | | |
916 | 918 | | |
917 | 919 | | |
918 | | - | |
| 920 | + | |
919 | 921 | | |
920 | 922 | | |
921 | 923 | | |
| |||
1536 | 1538 | | |
1537 | 1539 | | |
1538 | 1540 | | |
1539 | | - | |
| 1541 | + | |
1540 | 1542 | | |
1541 | 1543 | | |
1542 | 1544 | | |
| |||
1943 | 1945 | | |
1944 | 1946 | | |
1945 | 1947 | | |
| 1948 | + | |
| 1949 | + | |
1946 | 1950 | | |
1947 | 1951 | | |
1948 | 1952 | | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
1949 | 1963 | | |
1950 | 1964 | | |
1951 | 1965 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
8 | 27 | | |
9 | 28 | | |
10 | 29 | | |
| |||
28 | 47 | | |
29 | 48 | | |
30 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
31 | 61 | | |
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
Lines changed: 26 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
8 | 27 | | |
9 | 28 | | |
10 | 29 | | |
| |||
0 commit comments