// // VerificationManager.h // Filmage Screen // // Version 1.0.1 // // Created by 朱东勇 on 2018/2/8. // Copyright © 2018年 kdan mobile. All rights reserved. // #import //#import "ASIFormDataRequest.h" //#import "JSONKit.h" #define kTestMode 0 #if kTestMode #define kVerificationServer @"http://test-store.kdan.cn:3018/" #define kWebServerLink NSLocalizedString(@"http://test-pdf-pro.kdan.cn:3021", nil) #else #define kVerificationServer @"https://store.pdfreaderpro.com/" #define kWebServerLink NSLocalizedString(@"http://www.pdfreaderpro.com/store", nil) #endif #define kFetchLicenseCodeString [NSString stringWithFormat:@"%@/%@", kWebServerLink, @"store"] #define kLicenseRetrievalCodeString [NSString stringWithFormat:@"%@/%@", kWebServerLink, @"license_retrieval"] #define kFAQString [NSString stringWithFormat:@"%@/%@", kWebServerLink, @"faq"] #define kCheckUpdateURLString [NSString stringWithFormat:@"%@api/auth_devices/latest_version?lang=en&app_code=%@", kVerificationServer, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]?:@""] #define kFetchSysConfigInfoString [NSString stringWithFormat:@"%@/%@", kVerificationServer, @"api/sys_configs"] ///激活 typedef enum { ActivityErrorTypeCDKeyEmpty,//CD Key为空 ActivityErrorTypeCDKeyNotExist,//CD Key不存在 ActivityErrorTypeNetworkDisable,//网络不可用 ActivityErrorTypeOutNumber,//CD Key超出绑定数量,被其他设备使用 ActivityErrorTypeCDKeyExpire,//序列码过期 ActivityErrorTypeInvalidInfo,//激活错误,联系我们或查看FAQ ActivityErrorTypeNotMatchProduct,//CDkey是其他产品的 ActivityErrorTypeFormatError,//格式错误 ActivityErrorTypeUnknow,//未知错误 }ActivityErrorType; typedef enum { ActivityStatusNone, ActivityStatusTrial, //试用 ActivityStatusVerification, //激活 ActivityStatusTrialExpire, //试用过期 ActivityStatusVerifExpire, //过期 ActivityStatusLicenseExpire,//序列号过期 }ActivityStatus; typedef void(^ActivityComplention)(ActivityStatus status, NSDictionary *info, NSError *error); @interface VerificationManager : NSObject @property (nonatomic) BOOL autoVerification; //激活码定期自动校验,默认隔一小时校验一次 @property (nonatomic, readonly) ActivityStatus status; @property (nonatomic, readonly) BOOL needUpgradeLicense; @property (nonatomic, readonly) NSString *licenseCode; @property (nonatomic, readonly) NSString *originLicenseCode; @property (nonatomic, readonly) NSDictionary *detailInfo; @property (nonatomic, readonly) BOOL secondTrialEnabled; @property (nonatomic, readonly) NSInteger trialTimes; @property (nonatomic, readonly) NSString *email; @property (nonatomic, readonly) NSString *subscriptionEmail; @property (nonatomic, readonly) NSString *accountName; @property (nonatomic, readonly) BOOL allowUnbind; @property (nonatomic, readonly) NSInteger unbindTimes; + (VerificationManager *)manager; + (VerificationManager *)defaultManager; + (NSMutableData*)mutableDataWithDic:(NSDictionary*)dic; ///** 跳转到 Built to Connect 官网商城购买界面,各App可自行跳转到对应激活购买界面 // */ //- (void)fetchVerificationCode; /** 激活设备 @params info email 用户Email,可选 cdkey 用户用于激活设备的激活码,必选 */ - (void)activateDeviceWithInfo:(NSDictionary*)info complention:(ActivityComplention)complention; /** 验证设备信息 */ - (void)verificationWithComplention:(ActivityComplention)complention; /** 提交试用 @param days 申请试用天数,由App端指定,Server端会限定最大试用天数 @param email option, 申请人Email信息 */ - (void)trialForDays:(float)days email:(NSString*)email name:(NSString*)name complention:(ActivityComplention)complention; - (void)trialForDays:(float)days complention:(ActivityComplention)complention; /** 邀请部分 @param email 当前App使用的email 地址,用于接由试用体验邮件 */ - (void)getCodeWithEmail:(NSString*)email complention:(ActivityComplention)complention; /** 使用好友的邀请码 */ - (void)userCode:(NSString*)code complention:(ActivityComplention)complention; /** 修改用户email */ - (void)modifyEmail:(NSString*)email complention:(ActivityComplention)complention; /** 给好友发送邀请email, 多个email 使用 , 号分隔 */ - (void)sendInvateEmails:(NSString*)emails code:(NSString*)code complention:(ActivityComplention)complention; @end #pragma mark - Data Parse @interface NSDictionary (ActivityInfo) @property (nonatomic, readonly) ActivityStatus status; @property (nonatomic, readonly) NSDate *createDate; @property (nonatomic, readonly) NSDate *expireDate; @property (nonatomic, readonly) NSString *licenseCode; @property (nonatomic, readonly) NSString *originLicenseCode; @property (nonatomic, readonly) NSString *shareCode; @property (nonatomic, readonly) NSUInteger invateUsersCount; @property (nonatomic, readonly) NSDate *fetchInvateDate; @property (nonatomic, readonly) NSString *fromCode; @property (nonatomic, readonly) NSUInteger maxFreeDays; @property (nonatomic, readonly) BOOL repeatTrial; @property (nonatomic, readonly) NSString *email; @property (nonatomic, readonly) NSString *subscriptionEmail; @property (nonatomic, readonly) NSString *accountName; @property (nonatomic, readonly) NSUInteger trialTimes; @property (nonatomic, readonly) BOOL allowUnbind; @property (nonatomic, readonly) NSInteger unbindTimes; @end #if DEBUG @interface VerificationManager (Test) - (void)updateVerificationStatus; - (void)updateStatus:(ActivityStatus)status postNo:(bool)postNo; @end #endif /// Notification extern NSString *kDeviceVerifyFinishNotification;//调用验证接口结束后发送通知 extern NSString *kDeviceActivateStatusChangeNotification;