Skip to content

Commit

Permalink
Updating Appboy SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzhi committed Jun 16, 2017
1 parent 384b155 commit 200eb47
Show file tree
Hide file tree
Showing 59 changed files with 586 additions and 615 deletions.
12 changes: 4 additions & 8 deletions Appboy-iOS-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Appboy-iOS-SDK"
s.version = "2.29.1"
s.version = "2.30.0"
s.summary = "This is the Appboy iOS SDK for Mobile Marketing Automation"
s.homepage = "http://www.appboy.com"
s.license = { :type => 'Commercial', :text => 'Please refer to https://github.com/Appboy/appboy-ios-sdk/blob/master/LICENSE'}
Expand All @@ -17,20 +17,16 @@ Pod::Spec.new do |s|

s.subspec 'Core' do |sc|
sc.ios.library = 'z'
sc.frameworks = 'SystemConfiguration', 'QuartzCore', 'CoreText'
sc.source_files = 'AppboyKit/headers/AppboyKitLibrary/*.h', 'AppboyKit/ABKIdentifierForAdvertisingProvider.m'
sc.frameworks = 'SystemConfiguration', 'QuartzCore', 'CoreText', 'WebKit'
sc.source_files = 'AppboyKit/headers/AppboyKitLibrary/*.h', 'AppboyKit/ABKIdentifierForAdvertisingProvider.m', 'AppboyKit/ABKModalWebViewController.m', 'AppboyKit/ABKNoConnectionLocalization.m'
sc.vendored_libraries = 'AppboyKit/libAppboyKitLibrary.a'
sc.weak_framework = 'CoreTelephony', 'Social', 'Accounts', 'AdSupport', 'StoreKit','UserNotifications'
sc.resource = 'AppboyKit/Appboy.bundle'
end

s.subspec 'UI' do |sui|
sui.ios.library = 'z'
sui.frameworks = 'SystemConfiguration', 'QuartzCore', 'CoreImage', 'CoreText'
sui.source_files = 'AppboyKit/headers/AppboyKitLibrary/*.h', 'AppboyKit/*.m'
sui.vendored_libraries = 'AppboyKit/libAppboyKitLibrary.a'
sui.weak_framework = 'CoreTelephony', 'Social', 'Accounts', 'AdSupport', 'StoreKit','UserNotifications'
sui.resource = 'AppboyKit/Appboy.bundle'
sui.dependency 'SDWebImage/GIF', '~>4.0'
sui.dependency 'Appboy-iOS-SDK/Core'
end
end
170 changes: 170 additions & 0 deletions AppboyKit/ABKModalWebViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#import "ABKModalWebViewController.h"
#import "ABKNoConnectionLocalization.h"

static NSString *const titleKeyPath = @"title";
static NSString *const estimatedProgressKeyPath = @"estimatedProgress";
static NSString *const localizedNoConnectionKey = @"Appboy.no-connection.message";

@implementation ABKModalWebViewController

- (void)viewDidLoad {
[super viewDidLoad];

UIViewController *webViewController = [[UIViewController alloc] init];
webViewController.edgesForExtendedLayout = UIRectEdgeNone;

self.webView = [self getWebView];
webViewController.view = self.webView;

[self setupProgressBarWithViewController:webViewController];

UIBarButtonItem *closeBarButton = [self getDoneBarButtonItem];
[webViewController.navigationItem setRightBarButtonItem:closeBarButton];

[self.webView addObserver:self forKeyPath:titleKeyPath options:NSKeyValueObservingOptionNew context:nil];
[self.webView addObserver:self forKeyPath:estimatedProgressKeyPath options:NSKeyValueObservingOptionNew context:nil];

[self setViewControllers:@[webViewController]];

[self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary<NSKeyValueChangeKey,id> *)change
context:(void *)context {
if ([titleKeyPath isEqualToString:keyPath]) {
self.title = self.webView.title;
} else if ([estimatedProgressKeyPath isEqualToString:keyPath]) {
if (self.webView.estimatedProgress == 1.0) {
[UIView animateWithDuration:1 animations:^{
self.progressBar.alpha = 0.0;
}];
} else if (self.webView.estimatedProgress < 1.0) {
self.progressBar.alpha = 1.0;
[self.progressBar setProgress:self.webView.estimatedProgress animated:YES];
}
}
}

- (void)dealloc {
[self.webView removeObserver:self forKeyPath:titleKeyPath];
[self.webView removeObserver:self forKeyPath:estimatedProgressKeyPath];
}

#pragma mark - Customization Methods

/*!
* @discussion Returns a WKWebView object, whose navigationDelegate is this ABKModalWebViewController instance.
*
* If you want to do any customization to the WKWebView, please override this method in an ABKModalWebViewController
* category and return the customized WKWebView. All instances of ABKModalWebViewController will then
* call the category's `getWebView` implementation instead of this method.
*
*/
- (WKWebView *)getWebView {
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero];
webView.navigationDelegate = self;
return webView;
}

/*!
*
* @param viewController The view controller to which the progress bar will be added as a subview.
*
* @discussion Creates a UIProgressView and puts it on top of the param viewController.
*
* If you want to do any customization to the progress bar, please override this method in an ABKModalWebViewController
* category and set up the progress bar. All instances of ABKModalWebViewController will then
* call the category's `setupProgressBarWithViewController:` implementation instead of this method.
*
*/
- (void)setupProgressBarWithViewController:(UIViewController *)viewController {
UIProgressView *progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
progressBar.alpha = 0;
self.progressBar = progressBar;

[viewController.view addSubview:self.progressBar];
self.progressBar.translatesAutoresizingMaskIntoConstraints = NO;
[viewController.view addConstraint:[NSLayoutConstraint constraintWithItem:self.progressBar
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:viewController.topLayoutGuide
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:0.0]];
[viewController.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[progressBar]|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:@{@"progressBar" : self.progressBar}]];
}

/*!
* @discussion Returns the Done UIBarButtonItem, which allows the user to dismiss the modal web view.
*
* If you want to do any customization to the Done button, please override this method in an ABKModalWebViewController
* category and return the customized UIBarButtonItem. All instances of ABKModalWebViewController will then
* call the category's `getDoneBarButtonItem` implementation instead of this method.
*
*/
- (UIBarButtonItem *)getDoneBarButtonItem {
return [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(closeButtonPressed:)];
}

- (void)closeButtonPressed:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - WKNavigationDelegate methods

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
NSString *URLString = [[navigationAction.request.mainDocumentURL absoluteString] lowercaseString];
NSArray *stringComponents = [URLString componentsSeparatedByString:@":"];
if ([stringComponents[1] hasPrefix:@"//itunes.apple.com"] ||
(![stringComponents[0] isEqual:@"http"] &&
![stringComponents[0] isEqual:@"https"])) {
// Dismiss the modal web view and let the system handle the deep links
if ([[UIApplication sharedApplication] openURL:navigationAction.request.URL]) {
decisionHandler(WKNavigationActionPolicyCancel);
[self dismissViewControllerAnimated:YES completion:nil];
}
}
decisionHandler(WKNavigationActionPolicyAllow);
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
self.progressBar.alpha = 0.0;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation
withError:(NSError *)error{
self.progressBar.alpha = 0.0;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

// Display localized "No Connection" message
UILabel *label = [[UILabel alloc] init];
label.textAlignment = NSTextAlignmentCenter;
label.numberOfLines = 0;
NSString *localizedNoConectionMessage = NSLocalizedString(@"Appboy.no-connection.message", @"No connection error message for URL loading failure");
if (localizedNoConectionMessage.length == 0 || [localizedNoConnectionKey isEqualToString:localizedNoConectionMessage]) {
localizedNoConectionMessage = [ABKNoConnectionLocalization getNoConnectionLocalizedString];
}
label.text = localizedNoConectionMessage;
[self.webView addSubview:label];
label.translatesAutoresizingMaskIntoConstraints = NO;
[self.webView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[noConnectionLabel]-10-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:@{@"noConnectionLabel" : label}]];
[self.webView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[noConnectionLabel]|"
options:NSLayoutFormatAlignAllCenterY
metrics:nil
views:@{@"noConnectionLabel" : label}]];
}

@end
55 changes: 55 additions & 0 deletions AppboyKit/ABKNoConnectionLocalization.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#import "ABKNoConnectionLocalization.h"

@implementation ABKNoConnectionLocalization

+ (NSDictionary *)localizedNoConnectionStringDictionary {
return @{@"ar":@"لا يمكن إجراء الاتصال بالشبكة. يرجى تكرار المحاولة لاحقا.",
@"da":@"Kan ikke etablere netværksforbindelse. Prøv venligst senere.",
@"de":@"Netzwerkverbindung kann nicht aufgebaut werden. Bitte später noch einmal versuchen.",
@"en":@"Cannot establish network connection. Please try again later.",
@"es-419":@"No se puede establecer conexión con la red. Por favor, vuelva a intentarlo más tarde.",
@"es-MX":@"No se puede establecer conexión con la red. Por favor, vuelva a intentarlo más tarde.",
@"es":@"No se puede establecer conexión de red. Por favor inténtelo más tarde.",
@"et":@"Võrguühenduse loomine ebaõnnestus. Palun proovige hiljem uuesti.",
@"fi":@"Verkkoyhteyttä ei voida luoda. Yritä myöhemmin uudelleen.",
@"fil":@"Hindi makapagtatag ng koneksyon sa network. angyaring subukan muli mamaya.",
@"fr":@"Impossible d'établir la connexion réseau. Veuillez réessayer ultérieurement.",
@"he":@".לא ניתן לקבוע חיבור רשת.בבקשה נסה שוב בקרוב",
@"hi":@"नेटवर्क कनेक्शन स्थापित नहीं हो रहा है।. कृपया बाद में दोबारा प्रयास करें।.",
@"id":@"Tidak bisa melakukan koneksi jaringan. Coba lagi nanti.",
@"it":@"Impossibile stabilire una connessione di rete. Riprovare più tardi.",
@"ja":@"ネットワークに接続できません。後でもう一度試してください。",
@"km":@"មិនអាចបង្កើតបណ្តាញតភ្ជាប់បានទេ. សូមព្យាយាមម្តងទៀតនៅពេលក្រោយ.",
@"ko":@"네트워크 연결을 할 수 없습니다. 나중에 다시 시도해 주십시오.",
@"lo":@"ບໍ່​ສາ​ມາດ​ຕັ້ງ​ການ​ເຊື່ອມ​ຕໍ່​ເຄືອ​ຂ່າຍ​ໄດ້. ກະ​ລຸ​ນາ​ລອງ​ໃໝ່​ພາຍ​ຫຼັງ.",
@"ms":@"Tidak boleh membuat sambungan rangkaian. Sila cuba kemudian.",
@"my":@"ကြန္ယက္ဆက္သြယ္ျခင္း မျပဳလုပ္ႏိုင္ပါ။. ေက်းဇူးျပဳ၍ ထပ္မံၾကိဳးစားၾကည္႕ပါ။.",
@"nb":@"Kan ikke etablere nettverkstilkobling. Vennligst prøv igjen senere.",
@"nl":@"Kan geen netwerkverbinding maken. Probeer het later opnieuw.",
@"pl":@"Nie można ustanowić połączenia z siecią. Proszę spróbować ponownie później.",
@"pt-PT":@"Não é possível estabelecer a ligação à rede. Por favor, tente mais tarde.",
@"pt":@"Não é possível estabelecer uma conexão de rede. Tente novamente mais tarde.",
@"ru":@"Невозможно установить сетевое подключение. Пожалуйста, повторите попытку позже.",
@"sv":@"Det gick inte att skapa en nätverksanslutning. Försök igen senare.",
@"th":@"ไม่สามารถสร้างการเชื่อมต่อเครือข่าย. กรุณาลองใหม่ภายหลัง.",
@"vi":@"Không thể thiết lập kết nối mạng. Vui lòng thử lại sau.",
@"zh-Hans":@"无法建立网络连接。请稍候再试。",
@"zh-Hant":@"無法建立網路連線。請稍候再試。",
@"zh-HK":@"無法建立網路連線。請稍候再試。",
@"zh-TW":@"無法建立網路連線。請稍候再試。",
@"zh":@"无法建立网络连接。请稍候再试。"};
}

+ (NSString *)getNoConnectionLocalizedString {
NSString *language = [[NSLocale preferredLanguages] count]? [NSLocale preferredLanguages][0]: @"en";
NSDictionary *localizedStringDict = [self localizedNoConnectionStringDictionary];

while (localizedStringDict[language] == nil && [language rangeOfString:@"-"].location != NSNotFound) {
NSArray *languageComponent = [language componentsSeparatedByString:@"-"];
language = [[languageComponent subarrayWithRange:NSMakeRange(0, languageComponent.count - 1)] componentsJoinedByString:@"-"];
}
NSString *localizedString = localizedStringDict[language] ? localizedStringDict[language] : localizedStringDict[@"en"];
return localizedString;
}

@end
Binary file modified AppboyKit/Appboy.bundle/ABKBannerCardCell.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKCrossPromotionCardCell.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKFeedNoConnectionView.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKFeedbackContentView.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKFeedbackEmailViewPortrait.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKFeedbackNavBar.nib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKSpinnerView.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/ABKTextAnnouncementCardCell.nib
Binary file not shown.
Binary file modified AppboyKit/Appboy.bundle/Info.plist
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#import <UIKit/UIKit.h>


/*!
* Appboy Public API: ABKInAppMessageWindowController
*
* ABKInAppMessageWindowController is the view controller responsible for housing and displaying
* ABKInAppMessageViewControllers and performing actions after the in-app message is clicked. Instances
* of ABKInAppMessageWindowController are deallocated after the in-app message is dismissed.
*/
@interface ABKInAppMessageWindowController : UIViewController <UIGestureRecognizerDelegate>

@end
23 changes: 23 additions & 0 deletions AppboyKit/headers/AppboyKitLibrary/ABKModalWebViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>

@interface ABKModalWebViewController : UINavigationController <WKNavigationDelegate>

/*!
* The url the modal web view controller should open. Please note that this is the initial url and
* won't be updated if the initial url re-directs to another url.
*/
@property NSURL *url;

/*!
* The WKWebView which displays the web view.
*/
@property (nonatomic) IBOutlet WKWebView *webView;

/*!
* The UIProgressView which shows the web view loading process. It will be on top of the web view and
* will disappear as soon as the page is loaded.
*/
@property (nonatomic) IBOutlet UIProgressView *progressBar;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import <Foundation/Foundation.h>

@interface ABKNoConnectionLocalization : NSObject

+ (NSString *)getNoConnectionLocalizedString;

@end
Loading

0 comments on commit 200eb47

Please sign in to comment.