Skip to content

Commit

Permalink
Updating Unity plugins for version 3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
radixdev committed Aug 17, 2021
1 parent 337bf0c commit 9255b4e
Show file tree
Hide file tree
Showing 144 changed files with 561 additions and 272 deletions.
Binary file modified Assets/Plugins/Android/appboy-ui.aar
Binary file not shown.
Binary file modified Assets/Plugins/Android/appboy-unity.aar
Binary file not shown.
Binary file modified Assets/Plugins/Android/appboy.aar
Binary file not shown.
61 changes: 35 additions & 26 deletions Assets/Plugins/Appboy/Editor/PostBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ private static void ModifyProject(string path) {
project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Libraries");
project.SetBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "Yes");

// Note: Remove once Unity supports xcframeworks (SDK-1767).
project.SetBuildProperty(target, "VALIDATE_WORKSPACE", "Yes");

// Add required frameworks
// Note: Unity's documentation for PBXProject.AddFrameworkToProject says that the boolean parameter
// should be true if required and false if optional, but actual behavior appears to be the exact opposite.
Expand Down Expand Up @@ -157,75 +160,81 @@ private static void ModifyPlist(string plistPath) {
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;

// Clear existing Appboy Unity dictionary
// Migrate to Braze Unity dictionary if needed
if (rootDict["Appboy"] != null) {
rootDict["Appboy"]["Unity"] = null;
rootDict["Braze"] = rootDict["Appboy"];
rootDict["Appboy"] = null;
}

// Clear existing Braze Unity dictionary
if (rootDict["Braze"] != null) {
rootDict["Braze"]["Unity"] = null;
}

// Add Appboy Unity keys to Plist
// Add Braze Unity keys to Plist
if (AppboyConfig.IOSAutomatesIntegration) {
// The Appboy dictionary
PlistElementDict appboyDict = (rootDict["Appboy"] == null) ? rootDict.CreateDict("Appboy") : rootDict["Appboy"].AsDict();
// The Appboy Unity dictionary under the Appboy dictionary
PlistElementDict appboyUnityDict = appboyDict.CreateDict("Unity");
// The Braze dictionary
PlistElementDict brazeDict = (rootDict["Braze"] == null) ? rootDict.CreateDict("Braze") : rootDict["Braze"].AsDict();
// The Braze Unity dictionary under the Braze dictionary
PlistElementDict brazeUnityDict = brazeDict.CreateDict("Unity");

// Add the iOS Endpoint to Plist
if (string.IsNullOrEmpty(AppboyConfig.IOSEndpoint.Trim())) {
appboyDict.values.Remove(ABKEndpointKey);
brazeDict.values.Remove(ABKEndpointKey);
} else {
appboyDict.SetString(ABKEndpointKey, AppboyConfig.IOSEndpoint.Trim());
brazeDict.SetString(ABKEndpointKey, AppboyConfig.IOSEndpoint.Trim());
}
if (string.IsNullOrEmpty(AppboyConfig.IOSLogLevel.Trim())) {
appboyDict.values.Remove(ABKLogLevelKey);
brazeDict.values.Remove(ABKLogLevelKey);
} else {
appboyDict.SetString(ABKLogLevelKey, AppboyConfig.IOSLogLevel.Trim());
brazeDict.SetString(ABKLogLevelKey, AppboyConfig.IOSLogLevel.Trim());
}

// Add iOS automated integration build keys to Plist
if (ValidateField(ABKUnityApiKey, AppboyConfig.IOSApiKey, "Appboy will not be initialized.")) {
appboyUnityDict.SetString(ABKUnityApiKey, AppboyConfig.IOSApiKey.Trim());
brazeUnityDict.SetString(ABKUnityApiKey, AppboyConfig.IOSApiKey.Trim());
}
appboyUnityDict.SetBoolean(ABKUnityAutomaticPushIntegrationKey, AppboyConfig.IOSIntegratesPush);
appboyUnityDict.SetBoolean(ABKUnityDisableAutomaticPushRegistrationKey, AppboyConfig.IOSDisableAutomaticPushRegistration);
brazeUnityDict.SetBoolean(ABKUnityAutomaticPushIntegrationKey, AppboyConfig.IOSIntegratesPush);
brazeUnityDict.SetBoolean(ABKUnityDisableAutomaticPushRegistrationKey, AppboyConfig.IOSDisableAutomaticPushRegistration);
if (AppboyConfig.IOSPushIsBackgroundEnabled) {
PlistElementArray backgroundModes = (rootDict["UIBackgroundModes"] == null) ? rootDict.CreateArray("UIBackgroundModes") : rootDict["UIBackgroundModes"].AsArray();
backgroundModes.AddString("remote-notification");
}
appboyUnityDict.SetBoolean(ABKUnityDisableProvisionalAuthKey, AppboyConfig.IOSDisableProvisionalAuth);
brazeUnityDict.SetBoolean(ABKUnityDisableProvisionalAuthKey, AppboyConfig.IOSDisableProvisionalAuth);

// Set push listeners
if (ValidateListenerFields(ABKUnityPushReceivedGameObjectKey, AppboyConfig.IOSPushReceivedGameObjectName,
ABKUnityPushReceivedCallbackKey, AppboyConfig.IOSPushReceivedCallbackMethodName)) {
appboyUnityDict.SetString(ABKUnityPushReceivedGameObjectKey, AppboyConfig.IOSPushReceivedGameObjectName.Trim());
appboyUnityDict.SetString(ABKUnityPushReceivedCallbackKey, AppboyConfig.IOSPushReceivedCallbackMethodName.Trim());
brazeUnityDict.SetString(ABKUnityPushReceivedGameObjectKey, AppboyConfig.IOSPushReceivedGameObjectName.Trim());
brazeUnityDict.SetString(ABKUnityPushReceivedCallbackKey, AppboyConfig.IOSPushReceivedCallbackMethodName.Trim());
}

if (ValidateListenerFields(ABKUnityPushOpenedGameObjectKey, AppboyConfig.IOSPushOpenedGameObjectName,
ABKUnityPushOpenedCallbackKey, AppboyConfig.IOSPushOpenedCallbackMethodName)) {
appboyUnityDict.SetString(ABKUnityPushOpenedGameObjectKey, AppboyConfig.IOSPushOpenedGameObjectName.Trim());
appboyUnityDict.SetString(ABKUnityPushOpenedCallbackKey, AppboyConfig.IOSPushOpenedCallbackMethodName.Trim());
brazeUnityDict.SetString(ABKUnityPushOpenedGameObjectKey, AppboyConfig.IOSPushOpenedGameObjectName.Trim());
brazeUnityDict.SetString(ABKUnityPushOpenedCallbackKey, AppboyConfig.IOSPushOpenedCallbackMethodName.Trim());
}

// Set in-app message listener
if (ValidateListenerFields(ABKUnityInAppMessageGameObjectKey, AppboyConfig.IOSInAppMessageGameObjectName,
ABKUnityInAppMessageCallbackKey, AppboyConfig.IOSInAppMessageCallbackMethodName)) {
appboyUnityDict.SetString(ABKUnityInAppMessageGameObjectKey, AppboyConfig.IOSInAppMessageGameObjectName.Trim());
appboyUnityDict.SetString(ABKUnityInAppMessageCallbackKey, AppboyConfig.IOSInAppMessageCallbackMethodName.Trim());
appboyUnityDict.SetBoolean(ABKUnityHandleInAppMessageDisplayKey, AppboyConfig.IOSDisplayInAppMessages);
brazeUnityDict.SetString(ABKUnityInAppMessageGameObjectKey, AppboyConfig.IOSInAppMessageGameObjectName.Trim());
brazeUnityDict.SetString(ABKUnityInAppMessageCallbackKey, AppboyConfig.IOSInAppMessageCallbackMethodName.Trim());
brazeUnityDict.SetBoolean(ABKUnityHandleInAppMessageDisplayKey, AppboyConfig.IOSDisplayInAppMessages);
}

// Set feed listener
if (ValidateListenerFields(ABKUnityFeedGameObjectKey, AppboyConfig.IOSFeedGameObjectName,
ABKUnityFeedCallbackKey, AppboyConfig.IOSFeedCallbackMethodName)) {
appboyUnityDict.SetString(ABKUnityFeedGameObjectKey, AppboyConfig.IOSFeedGameObjectName.Trim());
appboyUnityDict.SetString(ABKUnityFeedCallbackKey, AppboyConfig.IOSFeedCallbackMethodName.Trim());
brazeUnityDict.SetString(ABKUnityFeedGameObjectKey, AppboyConfig.IOSFeedGameObjectName.Trim());
brazeUnityDict.SetString(ABKUnityFeedCallbackKey, AppboyConfig.IOSFeedCallbackMethodName.Trim());
}

// Set content card listener
if (ValidateListenerFields(ABKUnityContentCardsGameObjectKey, AppboyConfig.IOSContentCardsGameObjectName,
ABKUnityContentCardsCallbackKey, AppboyConfig.IOSContentCardsCallbackMethodName)) {
appboyUnityDict.SetString(ABKUnityContentCardsGameObjectKey, AppboyConfig.IOSContentCardsGameObjectName.Trim());
appboyUnityDict.SetString(ABKUnityContentCardsCallbackKey, AppboyConfig.IOSContentCardsCallbackMethodName.Trim());
brazeUnityDict.SetString(ABKUnityContentCardsGameObjectKey, AppboyConfig.IOSContentCardsGameObjectName.Trim());
brazeUnityDict.SetString(ABKUnityContentCardsCallbackKey, AppboyConfig.IOSContentCardsCallbackMethodName.Trim());
}
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public class ApplePushNotification {
// https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW10
public IDictionary<string, object> Extra { get; set; }

public ApplePushNotification(string jsonString) : this((JSONClass) JSON.Parse(jsonString)) {

}
public ApplePushNotification(string jsonString) : this((JSONClass) JSON.Parse(jsonString)) {}

public ApplePushNotification(JSONClass json) {
Alert = new ApplePushNotificationAlert(json["alert"].AsObject);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class PushNotification {
public Dictionary<string, string> Extras { get; private set; }
public int AndroidNotificationId { get; private set; }
public long AndroidPushReceivedTimestamp { get; private set; }
public string Deeplink { get; private set; }

public PushNotification(string message) {
if (String.IsNullOrEmpty(message)) {
Expand All @@ -24,6 +25,7 @@ public PushNotification(string message) {
}
Title = SafeGetString(json, "t", null);
Content = SafeGetString(json, "a", null);
Deeplink = SafeGetString(json, "uri", null);
AndroidNotificationId = SafeGetInt(json, "nid", -1);
AndroidPushReceivedTimestamp = SafeGetLong(json, "appboy_push_received_timestamp", -1);
if (json["extra"] != null) {
Expand All @@ -34,8 +36,8 @@ public PushNotification(string message) {
}

public override string ToString() {
return String.Format("PushNotification[Title={0}, Content={1}, Extras={2}, AndroidNotificationId={3}, AndroidPushReceivedTimestamp={4}, RawJson={5}]",
Title, Content, CollectionUtils.DictionaryToString(Extras), AndroidNotificationId, AndroidPushReceivedTimestamp, RawJsonString);
return String.Format("PushNotification[Title={0}, Content={1}, Extras={2}, AndroidNotificationId={3}, AndroidPushReceivedTimestamp={4}, Deeplink={5}, RawJson={6}]",
Title, Content, CollectionUtils.DictionaryToString(Extras), AndroidNotificationId, AndroidPushReceivedTimestamp, Deeplink, RawJsonString);
}

private string SafeGetString(JSONClass json, string key, string defaultValue) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/Plugins/iOS/AppboyUnityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef NS_ENUM(NSInteger, ABKUnityInAppMessageDisplayActionType) {

@interface AppboyUnityManager : NSObject <ABKInAppMessageControllerDelegate, UNUserNotificationCenterDelegate>

@property (nonatomic,copy) NSDictionary *appboyUnityPlist;
@property (nonatomic,copy) NSDictionary *brazeUnityPlist;
@property (nonatomic, copy) NSString *unityFeedGameObjectName;
@property (nonatomic, copy) NSString *unityFeedCallbackFunctionName;
@property (nonatomic, copy) NSString *unityContentCardsGameObjectName;
Expand Down
22 changes: 11 additions & 11 deletions Assets/Plugins/iOS/AppboyUnityManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ - (instancetype)init {
# pragma mark - Config

- (NSString *)getApiKeyFromUnity {
return self.appboyUnityPlist[ABKUnityApiKey];
return self.brazeUnityPlist[ABKUnityApiKey];
}

- (NSDictionary *)parsePlist {
NSDictionary* appboyUnityPlist = [[NSBundle mainBundle] infoDictionary][@"Appboy"][@"Unity"];
self.appboyUnityPlist = appboyUnityPlist;
return appboyUnityPlist;
NSDictionary* brazeUnityPlist = [[NSBundle mainBundle] infoDictionary][@"Braze"][@"Unity"];
self.brazeUnityPlist = brazeUnityPlist;
return brazeUnityPlist;
}

# pragma mark - Social Media
Expand Down Expand Up @@ -466,11 +466,11 @@ - (void)configureListenerFor:(NSInteger)messageType withGameObject:(NSString *)g
}

- (void)setListenersFromPList {
[self addPushReceivedListenerWithObjectName:self.appboyUnityPlist[ABKUnityPushReceivedGameObjectKey] callbackMethodName:self.appboyUnityPlist[ABKUnityPushReceivedCallbackKey]];
[self addPushOpenedListenerWithObjectName:self.appboyUnityPlist[ABKUnityPushOpenedGameObjectKey] callbackMethodName:self.appboyUnityPlist[ABKUnityPushOpenedCallbackKey]];
[self addInAppMessageListenerWithObjectNameAndSetDelegate:self.appboyUnityPlist[ABKUnityInAppMessageGameObjectKey] callbackMethodName:self.appboyUnityPlist[ABKUnityInAppMessageCallbackKey]];
[self addContentCardsListenerWithObjectName:self.appboyUnityPlist[ABKUnityContentCardsGameObjectKey] callbackMethodName:self.appboyUnityPlist[ABKUnityContentCardsCallbackKey]];
[self addFeedListenerWithObjectName:self.appboyUnityPlist[ABKUnityFeedGameObjectKey] callbackMethodName:self.appboyUnityPlist[ABKUnityFeedCallbackKey]];
[self addPushReceivedListenerWithObjectName:self.brazeUnityPlist[ABKUnityPushReceivedGameObjectKey] callbackMethodName:self.brazeUnityPlist[ABKUnityPushReceivedCallbackKey]];
[self addPushOpenedListenerWithObjectName:self.brazeUnityPlist[ABKUnityPushOpenedGameObjectKey] callbackMethodName:self.brazeUnityPlist[ABKUnityPushOpenedCallbackKey]];
[self addInAppMessageListenerWithObjectNameAndSetDelegate:self.brazeUnityPlist[ABKUnityInAppMessageGameObjectKey] callbackMethodName:self.brazeUnityPlist[ABKUnityInAppMessageCallbackKey]];
[self addContentCardsListenerWithObjectName:self.brazeUnityPlist[ABKUnityContentCardsGameObjectKey] callbackMethodName:self.brazeUnityPlist[ABKUnityContentCardsCallbackKey]];
[self addFeedListenerWithObjectName:self.brazeUnityPlist[ABKUnityFeedGameObjectKey] callbackMethodName:self.brazeUnityPlist[ABKUnityFeedCallbackKey]];
}

- (void)addInAppMessageListenerWithObjectNameAndSetDelegate:(NSString *)gameObject callbackMethodName:(NSString *)callbackMethod {
Expand Down Expand Up @@ -527,7 +527,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
completionHandler();
}

if ([self.appboyUnityPlist[ABKUnityAutomaticPushIntegrationKey] boolValue]) {
if ([self.brazeUnityPlist[ABKUnityAutomaticPushIntegrationKey] boolValue]) {
[[Appboy sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
[self forwardNotification:response.notification.request.content.userInfo];
}
Expand All @@ -547,7 +547,7 @@ - (ABKInAppMessageDisplayChoice)beforeInAppMessageDisplayed:(ABKInAppMessage *)i
NSData *inAppMessageData = [inAppMessage serializeToData];
NSString *dataString = [[NSString alloc] initWithData:inAppMessageData encoding:NSUTF8StringEncoding];
[self unitySendMessageTo:self.unityInAppMessageGameObjectName withMethod:self.unityInAppMessageCallbackFunctionName withMessage:dataString];
if ([self.appboyUnityPlist[ABKUnityHandleInAppMessageDisplayKey] boolValue]) {
if ([self.brazeUnityPlist[ABKUnityHandleInAppMessageDisplayKey] boolValue]) {
NSLog(@"Braze configured to display in-app messages despite presence of game object listener. Using display action: %ld.", (long)self.displayAction);
return self.displayAction;
}
Expand Down
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file modified Assets/Plugins/iOS/Appboy_iOS_SDK.framework/Appboy_iOS_SDK
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#import "ABKBaseContentCardCell.h"
#import "ABKBannerContentCard.h"
#import <SDWebImage/SDAnimatedImageView+WebCache.h>

@interface ABKBannerContentCardCell : ABKBaseContentCardCell

@property (weak, nonatomic) IBOutlet SDAnimatedImageView *bannerImageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageRatioConstraint;
@property (strong, nonatomic) IBOutlet UIImageView *bannerImageView;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imageRatioConstraint;

- (void)applyCard:(ABKBannerContentCard *)bannerCard;

- (void)updateImageConstraintsWithRatio:(CGFloat)newRatio;

@end
Loading

0 comments on commit 9255b4e

Please sign in to comment.