Skip to content

Commit aa67935

Browse files
author
Bryant Luk
committed
Add additional methods which hopefully do not collide with private API
- See #201
1 parent e1f5b3c commit aa67935

File tree

9 files changed

+93
-32
lines changed

9 files changed

+93
-32
lines changed

CardIO_Public_API/CardIOPaymentViewController.h

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,11 @@
4040
/// ar,da,de,en,en_AU,en_GB,es,es_MX,fr,he,is,it,ja,ko,ms,nb,nl,pl,pt,pt_BR,ru,sv,th,tr,zh-Hans,zh-Hant,zh-Hant_TW.
4141
@property(nonatomic, copy, readwrite) NSString *languageOrLocale;
4242

43-
/// If YES, the status bar's style will be kept as whatever your app has set it to.
44-
/// If NO, the status bar style will be set to the default style.
45-
/// Defaults to NO.
43+
/// @see keepStatusBarStyleForCardIO
4644
@property(nonatomic, assign, readwrite) BOOL keepStatusBarStyle;
47-
48-
/// The default appearance of the navigation bar is navigationBarStyle == UIBarStyleDefault;
49-
/// tintColor == nil (pre-iOS 7), barTintColor == nil (iOS 7).
50-
/// Set either or both of these properties if you want to override these defaults.
51-
/// @see navigationBarTintColor
45+
/// @see navigationBarStyleForCardIO
5246
@property(nonatomic, assign, readwrite) UIBarStyle navigationBarStyle;
53-
/// The default appearance of the navigation bar is navigationBarStyle == UIBarStyleDefault;
54-
/// tintColor == nil (pre-iOS 7), barTintColor == nil (iOS 7).
55-
/// Set either or both of these properties if you want to override these defaults.
56-
/// @see navigationBarStyle
47+
/// @see navigationBarTintColorForCardIO
5748
@property(nonatomic, retain, readwrite) UIColor *navigationBarTintColor;
5849

5950
/// Normally, card.io blurs the screen when the app is backgrounded,
@@ -183,3 +174,25 @@ extern NSString * const CardIOCurrentScanningOrientation;
183174
extern NSString * const CardIOScanningOrientationAnimationDuration;
184175

185176
@end
177+
178+
/// Methods with names that do not conflict with Apple's private APIs.
179+
@interface CardIOPaymentViewController (NonConflictingAPINames)
180+
181+
/// If YES, the status bar's style will be kept as whatever your app has set it to.
182+
/// If NO, the status bar style will be set to the default style.
183+
/// Defaults to NO.
184+
@property(nonatomic, assign, readwrite) BOOL keepStatusBarStyleForCardIO;
185+
186+
/// The default appearance of the navigation bar is navigationBarStyleForCardIO == UIBarStyleDefault;
187+
/// tintColor == nil (pre-iOS 7), barTintColor == nil (iOS 7).
188+
/// Set either or both of these properties if you want to override these defaults.
189+
/// @see navigationBarTintColorForCardIO
190+
@property(nonatomic, assign, readwrite) UIBarStyle navigationBarStyleForCardIO;
191+
192+
/// The default appearance of the navigation bar is navigationBarStyleForCardIO == UIBarStyleDefault;
193+
/// tintColor == nil (pre-iOS 7), barTintColor == nil (iOS 7).
194+
/// Set either or both of these properties if you want to override these defaults.
195+
/// @see navigationBarStyleForCardIO
196+
@property(nonatomic, retain, readwrite) UIColor *navigationBarTintColorForCardIO;
197+
198+
@end

CardIO_Public_API/CardIOUtilities.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,19 @@
3333
+ (UIImageView *)blurredScreenImageView;
3434

3535
@end
36+
37+
/// Methods with names that do not conflict with Apple's private APIs.
38+
@interface CardIOUtilities (NonConflictingAPINames)
39+
40+
/// Please send the output of this method with any technical support requests.
41+
/// @return Human-readable version of this library.
42+
+ (NSString *)cardIOLibraryVersion;
43+
44+
/// The preload method prepares card.io to launch faster. Calling preload is optional but suggested.
45+
/// On an iPhone 5S, for example, preloading makes card.io launch ~400ms faster.
46+
/// The best time to call preload is when displaying a view from which card.io might be launched;
47+
/// e.g., inside your view controller's viewWillAppear: method.
48+
/// preload works in the background; the call to preload returns immediately.
49+
+ (void)preloadCardIO;
50+
51+
@end

Classes/CardIOContext.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
@property(nonatomic, assign, readwrite) BOOL restrictPostalCodeToNumericOnly;
2323
@property(nonatomic, assign, readwrite) BOOL collectCardholderName;
2424
@property(nonatomic, assign, readwrite) BOOL disableManualEntryButtons;
25-
@property(nonatomic, assign, readwrite) BOOL keepStatusBarStyle;
26-
@property(nonatomic, assign, readwrite) UIBarStyle navigationBarStyle;
27-
@property(nonatomic, retain, readwrite) UIColor *navigationBarTintColor;
25+
@property(nonatomic, assign, readwrite) BOOL keepStatusBarStyleForCardIO;
26+
@property(nonatomic, assign, readwrite) UIBarStyle navigationBarStyleForCardIO;
27+
@property(nonatomic, retain, readwrite) UIColor *navigationBarTintColorForCardIO;
2828
@property(nonatomic, assign, readwrite) BOOL disableBlurWhenBackgrounding;
2929
@property(nonatomic, assign, readwrite) BOOL suppressScanConfirmation;
3030
@property(nonatomic, assign, readwrite) BOOL suppressScannedCardImage;
@@ -50,4 +50,4 @@
5050

5151
@property(nonatomic, assign, readwrite) BOOL scanExpiry;
5252

53-
@end
53+
@end

Classes/CardIODataEntryViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ - (void)viewWillAppear:(BOOL)animated {
409409
}
410410
}
411411

412-
if (!self.context.keepStatusBarStyle) {
412+
if (!self.context.keepStatusBarStyleForCardIO) {
413413
if (iOS_7_PLUS) {
414414
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
415415
}

Classes/CardIOPaymentViewController.m

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ - (void)viewWillAppear:(BOOL)animated {
111111
self.shouldStoreStatusBarStyle = NO; // only store the very first time
112112
}
113113

114-
self.navigationBar.barStyle = self.context.navigationBarStyle;
114+
self.navigationBar.barStyle = self.context.navigationBarStyleForCardIO;
115115
if (iOS_7_PLUS) {
116-
self.navigationBar.barTintColor = self.context.navigationBarTintColor;
116+
self.navigationBar.barTintColor = self.context.navigationBarTintColorForCardIO;
117117
}
118118
else {
119-
self.navigationBar.tintColor = self.context.navigationBarTintColor;
119+
self.navigationBar.tintColor = self.context.navigationBarTintColorForCardIO;
120120
}
121121

122122
[super viewWillAppear:animated];
123123

124-
if (self.modalPresentationStyle == UIModalPresentationFullScreen && !self.context.keepStatusBarStyle) {
124+
if (self.modalPresentationStyle == UIModalPresentationFullScreen && !self.context.keepStatusBarStyleForCardIO) {
125125
if (iOS_7_PLUS) {
126126
[theApp setStatusBarStyle:UIStatusBarStyleDefault animated:animated];
127127
}
@@ -186,6 +186,30 @@ - (void)dealloc {
186186
[[NSNotificationCenter defaultCenter] removeObserver:self];
187187
}
188188

189+
- (void)setKeepStatusBarStyle:(BOOL)keepStatusBarStyle {
190+
self.keepStatusBarStyleForCardIO = keepStatusBarStyle;
191+
}
192+
193+
- (BOOL)keepStatusBarStyle {
194+
return self.keepStatusBarStyleForCardIO;
195+
}
196+
197+
- (void)setNavigationBarStyle:(UIBarStyle)navigationBarStyle {
198+
self.navigationBarStyleForCardIO = navigationBarStyle;
199+
}
200+
201+
- (UIBarStyle)navigationBarStyle {
202+
return self.navigationBarStyleForCardIO;
203+
}
204+
205+
- (void)setNavigationBarTintColor:(UIColor *)navigationBarTintColor {
206+
self.navigationBarTintColorForCardIO = navigationBarTintColor;
207+
}
208+
209+
- (UIColor *)navigationBarTintColor {
210+
return self.navigationBarTintColorForCardIO;
211+
}
212+
189213
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
190214
if (self.currentViewControllerIsDataEntry) {
191215
return YES;
@@ -339,7 +363,7 @@ - (void)didReceiveForegroundingNotification:(NSNotification *)notification {
339363
- (NSString *)description {
340364
return [NSString stringWithFormat:@"{delegate: %@; %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}"
341365
,self.paymentDelegate
342-
,DESCRIBE_BOOL(keepStatusBarStyle)
366+
,DESCRIBE_BOOL(keepStatusBarStyleForCardIO)
343367
,DESCRIBE_BOOL(disableBlurWhenBackgrounding)
344368
,DESCRIBE_BOOL(suppressScanConfirmation)
345369
,DESCRIBE_BOOL(suppressScannedCardImage)
@@ -380,9 +404,9 @@ - (void)set##prop_uc:(t)prop_lc { \
380404

381405

382406
CONTEXT_PASSTHROUGH_READWRITE(NSString *, languageOrLocale, LanguageOrLocale)
383-
CONTEXT_PASSTHROUGH_READWRITE(BOOL, keepStatusBarStyle, KeepStatusBarStyle)
384-
CONTEXT_PASSTHROUGH_READWRITE(UIBarStyle, navigationBarStyle, NavigationBarStyle)
385-
CONTEXT_PASSTHROUGH_READWRITE(UIColor *, navigationBarTintColor, NavigationBarTintColor)
407+
CONTEXT_PASSTHROUGH_READWRITE(BOOL, keepStatusBarStyleForCardIO, KeepStatusBarStyleForCardIO)
408+
CONTEXT_PASSTHROUGH_READWRITE(UIBarStyle, navigationBarStyleForCardIO, NavigationBarStyleForCardIO)
409+
CONTEXT_PASSTHROUGH_READWRITE(UIColor *, navigationBarTintColorForCardIO, NavigationBarTintColorForCardIO)
386410
CONTEXT_PASSTHROUGH_READWRITE(BOOL, disableBlurWhenBackgrounding, DisableBlurWhenBackgrounding)
387411
CONTEXT_PASSTHROUGH_READWRITE(BOOL, collectCVV, CollectCVV)
388412
CONTEXT_PASSTHROUGH_READWRITE(BOOL, collectPostalCode, CollectPostalCode)

Classes/CardIOUtilities.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ @implementation CardIOUtilities
1919
#pragma mark - Library version, for bug reporting etc.
2020

2121
+ (NSString *)libraryVersion {
22+
return [self cardIOLibraryVersion];
23+
}
24+
25+
+ (NSString *)cardIOLibraryVersion {
2226
NSString *dateString = [[[NSString stringWithUTF8String:__DATE__] stringByReplacingOccurrencesOfString:@" " withString:@"."] stringByReplacingOccurrencesOfString:@".." withString:@"."];
2327
NSString *timeHash = [NSString stringWithUTF8String:__TIME__];
2428
NSMutableString *libraryVersion = [NSMutableString stringWithFormat:@"%@-%@", dateString, timeHash];
@@ -108,10 +112,14 @@ + (BOOL)canReadCardWithCamera {
108112

109113
#pragma mark - Preload resources for faster launch of card.io
110114

111-
+ (void)preload {
115+
+ (void)preloadCardIO {
112116
[CardIOLocalizer preload];
113117
}
114118

119+
+ (void)preload {
120+
[self preloadCardIO];
121+
}
122+
115123
#pragma mark - Screen obfuscation on backgrounding
116124

117125
+ (UIImageView *)blurredScreenImageView {

Classes/RootViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ - (void)viewDidLoad {
361361
[TestGeneratedModels selfCheck];
362362
#endif
363363

364-
[CardIOUtilities preload];
364+
[CardIOUtilities preloadCardIO];
365365
}
366366

367367
- (UIStatusBarStyle) preferredStatusBarStyle {

Classes/iccAppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
1919
self.window.rootViewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
2020
[self.window addSubview:self.window.rootViewController.view];
2121
[self.window makeKeyAndVisible];
22-
CardIOLog(@"Client version is %@.", [CardIOUtilities libraryVersion]);
22+
CardIOLog(@"Client version is %@.", [CardIOUtilities cardIOLibraryVersion]);
2323
return YES;
2424
}
2525

Release/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Make an optional call to speed up the subsequent launch of card.io scanning:
125125
126126
- (void)viewWillAppear:(BOOL)animated {
127127
[super viewWillAppear:animated];
128-
[CardIOUtilities preload];
128+
[CardIOUtilities preloadCardIO];
129129
}
130130
131131
```
@@ -202,7 +202,7 @@ Make an optional call to speed up the subsequent launch of card.io scanning:
202202

203203
- (void)viewWillAppear:(BOOL)animated {
204204
[super viewWillAppear:animated];
205-
[CardIOUtilities preload];
205+
[CardIOUtilities preloadCardIO];
206206
}
207207

208208
```
@@ -287,7 +287,7 @@ Make an optional call to speed up the subsequent launch of card.io scanning:
287287

288288
- (void)viewWillAppear:(BOOL)animated {
289289
[super viewWillAppear:animated];
290-
[CardIOUtilities preload];
290+
[CardIOUtilities preloadCardIO];
291291
}
292292

293293
```
@@ -338,4 +338,4 @@ Include a method to cancel card scanning:
338338
* Processing images can be memory intensive, so make sure to test that your app properly handles memory warnings.
339339
* For your users' security, [obscure your app's cached screenshots](https://viaforensics.com/resources/reports/best-practices-ios-android-secure-mobile-development/ios-avoid-cached-application-snapshots/).
340340
**Note:** By default, a `CardIOPaymentViewController` automatically blurs its own screens when the app is backgrounded. A `CardIOView` does not do any automatic blurring.
341-
* The first time that you create either a `CardIOPaymentViewController` or a `CardIOView`, the card.io SDK must load resources, which can result in a noticeable delay. To avoid this delay you may optionally call `[CardIOUtilities preload]` in advance, so that this resource loading occurs in advance on a background thread.
341+
* The first time that you create either a `CardIOPaymentViewController` or a `CardIOView`, the card.io SDK must load resources, which can result in a noticeable delay. To avoid this delay you may optionally call `[CardIOUtilities preloadCardIO]` in advance, so that this resource loading occurs in advance on a background thread.

0 commit comments

Comments
 (0)