Skip to content

Commit 4eebc17

Browse files
Release 8.0.0
1 parent 8be21d4 commit 4eebc17

File tree

15 files changed

+296
-119
lines changed

15 files changed

+296
-119
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ jobs:
1717
run: |
1818
sudo apt-get install doxygen
1919
./gradlew docs:build
20-
21-
- name: Build
20+
21+
# Build
22+
- name: Build project
2223
env:
2324
UNITY_USERNAME: ${{ secrets.UNITY_USERNAME }}
2425
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}

Assets/Plugins/Android/urbanairship-resources/AndroidManifest.xml renamed to Assets/Plugins/Android/urbanairship-resources.androidlib/AndroidManifest.xml

File renamed without changes.

Assets/Plugins/Android/urbanairship-resources/project.properties renamed to Assets/Plugins/Android/urbanairship-resources.androidlib/project.properties

File renamed without changes.

Assets/Plugins/iOS/UAUnityMessageViewController.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
/* Copyright Urban Airship and Contributors */
22

3-
#if __has_include("AirshipLib.h")
4-
#import "AirshipLib.h"
5-
#import "AirshipMessageCenterLib.h"
3+
#if __has_include("UAirship.h")
4+
#import "UAirship.h"
5+
#import "UAMessageCenter.h"
6+
#import "UAInboxMessage.h"
7+
#import "UAInboxMessageList.h"
8+
#import "UAMessageCenterMessageViewDelegate.h"
9+
#import "UADefaultMessageCenterMessageViewController.h"
10+
#import "UAMessageCenterResources.h"
11+
#import "UAMessageCenterLocalization.h"
612
#else
713
@import Airship;
814
#endif
915

1016
NS_ASSUME_NONNULL_BEGIN
1117

12-
@interface UAUnityMessageViewController : UAMessageCenterMessageViewController
18+
@interface UAUnityMessageViewController : UINavigationController
19+
20+
- (void)loadMessageForID:(nullable NSString *)messageID;
1321

1422
@end
1523

Assets/Plugins/iOS/UAUnityMessageViewController.m

Lines changed: 147 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,158 @@
22

33
#import "UAUnityMessageViewController.h"
44

5+
@interface UAUnityMessageViewController() <UAMessageCenterMessageViewDelegate>
6+
@property (nonatomic, strong) UADefaultMessageCenterMessageViewController *airshipMessageViewController;
7+
@end
8+
59
@implementation UAUnityMessageViewController
610

7-
- (void) viewDidLoad {
8-
[super viewDidLoad];
9-
10-
UIBarButtonItem *done = [[UIBarButtonItem alloc]
11-
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
12-
target:self
13-
action:@selector(dismissMessageViewController:)];
14-
15-
self.navigationItem.rightBarButtonItem = done;
16-
17-
__weak UAUnityMessageViewController *weakSelf = self;
18-
self.closeBlock = ^(BOOL animated) {
19-
[weakSelf dismissViewControllerAnimated:animated completion:nil];
20-
};
11+
- (instancetype)init {
12+
self = [super init];
13+
14+
if (self) {
15+
self.airshipMessageViewController = [[UADefaultMessageCenterMessageViewController alloc] initWithNibName:@"UADefaultMessageCenterMessageViewController"
16+
bundle:[UAMessageCenterResources bundle]];
17+
self.airshipMessageViewController.delegate = self;
18+
19+
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
20+
target:self
21+
action:@selector(inboxMessageDone:)];
22+
23+
self.airshipMessageViewController.navigationItem.leftBarButtonItem = done;
24+
25+
self.viewControllers = @[self.airshipMessageViewController];
26+
27+
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
28+
self.modalPresentationStyle = UIModalPresentationFullScreen;
29+
}
30+
31+
return self;
2132
}
2233

23-
- (void) dismissMessageViewController:(id)sender {
34+
- (void)inboxMessageDone:(id)sender {
2435
[self dismissViewControllerAnimated:true completion:nil];
2536
}
2637

38+
- (void)loadMessageForID:(NSString *)messageID {
39+
[self.airshipMessageViewController loadMessageForID:messageID];
40+
}
41+
42+
#pragma mark UAMessageCenterMessageViewDelegate
43+
44+
- (void)messageClosed:(NSString *)messageID {
45+
[self dismissViewControllerAnimated:YES completion:nil];
46+
}
47+
48+
- (void)messageLoadStarted:(NSString *)messageID {
49+
// no-op
50+
}
51+
52+
- (void)messageLoadSucceeded:(NSString *)messageID {
53+
// no-op
54+
}
55+
56+
- (void)displayFailedToLoadAlertOnOK:(void (^)(void))okCompletion onRetry:(void (^)(void))retryCompletion {
57+
UIAlertController* alert = [UIAlertController alertControllerWithTitle:UAMessageCenterLocalizedString(@"ua_connection_error")
58+
message:UAMessageCenterLocalizedString(@"ua_mc_failed_to_load")
59+
preferredStyle:UIAlertControllerStyleAlert];
60+
61+
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:UAMessageCenterLocalizedString(@"ua_ok")
62+
style:UIAlertActionStyleDefault
63+
handler:^(UIAlertAction * action) {
64+
if (okCompletion) {
65+
okCompletion();
66+
}
67+
}];
68+
69+
[alert addAction:defaultAction];
70+
71+
if (retryCompletion) {
72+
UIAlertAction *retryAction = [UIAlertAction actionWithTitle:UAMessageCenterLocalizedString(@"ua_retry_button")
73+
style:UIAlertActionStyleDefault
74+
handler:^(UIAlertAction * _Nonnull action) {
75+
if (retryCompletion) {
76+
retryCompletion();
77+
}
78+
}];
79+
80+
[alert addAction:retryAction];
81+
}
82+
83+
[self presentViewController:alert animated:YES completion:nil];
84+
}
85+
86+
- (void)displayNoLongerAvailableAlertOnOK:(void (^)(void))okCompletion {
87+
UIAlertController* alert = [UIAlertController alertControllerWithTitle:UAMessageCenterLocalizedString(@"ua_content_error")
88+
message:UAMessageCenterLocalizedString(@"ua_mc_no_longer_available")
89+
preferredStyle:UIAlertControllerStyleAlert];
90+
91+
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:UAMessageCenterLocalizedString(@"ua_ok")
92+
style:UIAlertActionStyleDefault
93+
handler:^(UIAlertAction * action) {
94+
if (okCompletion) {
95+
okCompletion();
96+
}
97+
}];
98+
99+
[alert addAction:defaultAction];
100+
101+
[self presentViewController:alert animated:YES completion:nil];
102+
}
103+
104+
- (void)messageLoadFailed:(NSString *)messageID error:(NSError *)error {
105+
UA_LTRACE(@"message load failed: %@", messageID);
106+
107+
void (^retry)(void) = ^{
108+
UA_WEAKIFY(self);
109+
[self displayFailedToLoadAlertOnOK:^{
110+
UA_STRONGIFY(self)
111+
[self dismissViewControllerAnimated:true completion:nil];
112+
} onRetry:^{
113+
UA_STRONGIFY(self)
114+
[self loadMessageForID:messageID];
115+
}];
116+
};
117+
118+
void (^handleFailed)(void) = ^{
119+
UA_WEAKIFY(self);
120+
[self displayFailedToLoadAlertOnOK:^{
121+
UA_STRONGIFY(self)
122+
[self dismissViewControllerAnimated:true completion:nil];
123+
} onRetry:nil];
124+
};
125+
126+
void (^handleExpired)(void) = ^{
127+
UA_WEAKIFY(self);
128+
[self displayNoLongerAvailableAlertOnOK:^{
129+
UA_STRONGIFY(self)
130+
[self dismissViewControllerAnimated:true completion:nil];
131+
}];
132+
};
133+
134+
if ([error.domain isEqualToString:UAMessageCenterMessageLoadErrorDomain]) {
135+
if (error.code == UAMessageCenterMessageLoadErrorCodeFailureStatus) {
136+
// Encountered a failure status code
137+
NSUInteger status = [error.userInfo[UAMessageCenterMessageLoadErrorHTTPStatusKey] unsignedIntValue];
138+
139+
if (status >= 500) {
140+
retry();
141+
} else if (status == 410) {
142+
// Gone: message has been permanently deleted from the backend.
143+
handleExpired();
144+
} else {
145+
handleFailed();
146+
}
147+
} else if (error.code == UAMessageCenterMessageLoadErrorCodeMessageExpired) {
148+
handleExpired();
149+
} else {
150+
retry();
151+
}
152+
} else {
153+
// Other errors
154+
retry();
155+
}
156+
}
157+
27158
@end
159+

Assets/Plugins/iOS/UAUnityPlugin.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
/* Copyright Airship and Contributors */
22

33
#import <Foundation/Foundation.h>
4-
#import "AirshipLib.h"
5-
#import "AirshipMessageCenterLib.h"
4+
#if __has_include("UAirship.h")
5+
#import "UAirship.h"
6+
#import "UAMessageCenter.h"
7+
#import "UAPush.h"
8+
#import "UAInboxMessage.h"
9+
#import "UAAnalytics.h"
10+
#import "UAInboxMessageList.h"
11+
#import "UAInAppAutomation.h"
12+
#import "UADefaultMessageCenterUI.h"
13+
#import "UAAssociatedIdentifiers.h"
14+
#else
15+
@import Airship;
16+
#endif
617

718
extern void UnitySendMessage(const char *, const char *, const char *);
819

@@ -91,7 +102,7 @@ void UAUnityPlugin_setDataCollectionEnabled(bool enabled);
91102
bool UAUnityPlugin_isPushTokenRegistrationEnabled();
92103
void UAUnityPlugin_setPushTokenRegistrationEnabled(bool enabled);
93104

94-
@interface UAUnityPlugin : NSObject <UAPushNotificationDelegate, UARegistrationDelegate, UADeepLinkDelegate, UAMessageCenterDisplayDelegate>
105+
@interface UAUnityPlugin : NSObject <UAPushNotificationDelegate, UADeepLinkDelegate, UAMessageCenterDisplayDelegate>
95106

96107
+ (UAUnityPlugin *)shared;
97108

0 commit comments

Comments
 (0)