|
| 1 | +// |
| 2 | +// BranchQRCode.h |
| 3 | +// Branch |
| 4 | +// |
| 5 | +// Created by Nipun Singh on 3/22/22. |
| 6 | +// Copyright © 2022 Branch, Inc. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import "BranchUniversalObject.h" |
| 10 | +#import "BranchLinkProperties.h" |
| 11 | + |
| 12 | +NS_ASSUME_NONNULL_BEGIN |
| 13 | + |
| 14 | +typedef NS_ENUM(NSInteger, BranchQRCodeImageFormat){ |
| 15 | + BranchQRCodeImageFormatPNG, |
| 16 | + BranchQRCodeImageFormatJPEG |
| 17 | +}; |
| 18 | + |
| 19 | +@interface BranchQRCode : NSObject |
| 20 | + |
| 21 | +/// Primary color of the generated QR code itself. |
| 22 | +@property (nonatomic, strong, readwrite) UIColor *codeColor; |
| 23 | +/// Secondary color used as the QR Code background. |
| 24 | +@property (nonatomic, strong, readwrite) UIColor *backgroundColor; |
| 25 | +/// A URL of an image that will be added to the center of the QR code. Must be a PNG or JPEG. |
| 26 | +@property (nonatomic, copy, readwrite) NSString *centerLogo; |
| 27 | +/// Output size of QR Code image. Min 300px. Max 2000px. |
| 28 | +@property (nonatomic, copy, readwrite) NSNumber *width; |
| 29 | +/// The number of pixels for the QR code's border. Min 1px. Max 20px. |
| 30 | +@property (nonatomic, copy, readwrite) NSNumber *margin; |
| 31 | +/// Format of the returned QR code. Can be a JPEG or PNG. |
| 32 | +@property (nonatomic, assign, readwrite) BranchQRCodeImageFormat imageFormat; |
| 33 | + |
| 34 | +/** |
| 35 | +Creates a Branch QR Code image. Returns the QR code as NSData. |
| 36 | +
|
| 37 | +@param buo The Branch Universal Object the will be shared. |
| 38 | +@param lp The link properties that the link will have. |
| 39 | +@param completion Completion handler containing the QR code image and error. |
| 40 | +
|
| 41 | +*/ |
| 42 | +- (void)getQRCodeAsData:(nullable BranchUniversalObject *)buo |
| 43 | + linkProperties:(nullable BranchLinkProperties *)lp |
| 44 | + completion:(void(^)(NSData * _Nullable qrCode, NSError * _Nullable error))completion; |
| 45 | + |
| 46 | +/** |
| 47 | +Creates a Branch QR Code image. Returns the QR code as a UIImage. |
| 48 | +
|
| 49 | +@param buo The Branch Universal Object the will be shared. |
| 50 | +@param lp The link properties that the link will have. |
| 51 | +@param completion Completion handler containing the QR code image and error. |
| 52 | +
|
| 53 | +*/ |
| 54 | +- (void)getQRCodeAsImage:(nullable BranchUniversalObject *)buo |
| 55 | + linkProperties:(nullable BranchLinkProperties *)lp |
| 56 | + completion:(void(^)(UIImage * _Nullable qrCode, NSError * _Nullable error))completion; |
| 57 | + |
| 58 | + |
| 59 | +/** |
| 60 | +Creates a Branch QR Code image and displays it in a share sheet. |
| 61 | +
|
| 62 | +@param buo The Branch Universal Object the will be shared. |
| 63 | +@param lp The link properties that the link will have. |
| 64 | +@param completion Completion handler containing any potential error. |
| 65 | + |
| 66 | + */ |
| 67 | +#if !TARGET_OS_TV |
| 68 | +- (void)showShareSheetWithQRCodeFromViewController:(nullable UIViewController *)viewController |
| 69 | + anchor:(nullable id)anchorViewOrButtonItem |
| 70 | + universalObject:(nullable BranchUniversalObject *)buo |
| 71 | + linkProperties:(nullable BranchLinkProperties *)lp |
| 72 | + completion:(void(^)(NSError * _Nullable error))completion; |
| 73 | +#endif |
| 74 | + |
| 75 | +@end |
| 76 | + |
| 77 | +NS_ASSUME_NONNULL_END |
| 78 | + |
0 commit comments