VerificationManager.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //
  2. // VerificationManager.h
  3. // Filmage Screen
  4. //
  5. // Version 1.0.1
  6. //
  7. // Created by 朱东勇 on 2018/2/8.
  8. // Copyright © 2018年 kdan mobile. All rights reserved.
  9. //
  10. #import <Foundation/Foundation.h>
  11. //#import "ASIFormDataRequest.h"
  12. //#import "JSONKit.h"
  13. #define kTestMode 0
  14. #if kTestMode
  15. #define kVerificationServer @"http://test-store.kdan.cn:3018/"
  16. #define kWebServerLink NSLocalizedString(@"http://test-pdf-pro.kdan.cn:3021", nil)
  17. #else
  18. #define kVerificationServer @"https://store.pdfreaderpro.com/"
  19. #define kWebServerLink NSLocalizedString(@"http://www.pdfreaderpro.com/store", nil)
  20. #endif
  21. #define kFetchLicenseCodeString [NSString stringWithFormat:@"%@/%@", kWebServerLink, @"store"]
  22. #define kLicenseRetrievalCodeString [NSString stringWithFormat:@"%@/%@", kWebServerLink, @"license_retrieval"]
  23. #define kFAQString [NSString stringWithFormat:@"%@/%@", kWebServerLink, @"faq"]
  24. #define kCheckUpdateURLString [NSString stringWithFormat:@"%@api/auth_devices/latest_version?lang=en&app_code=%@", kVerificationServer, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]?:@""]
  25. #define kFetchSysConfigInfoString [NSString stringWithFormat:@"%@/%@", kVerificationServer, @"api/sys_configs"]
  26. ///激活
  27. typedef enum {
  28. ActivityErrorTypeCDKeyEmpty,//CD Key为空
  29. ActivityErrorTypeCDKeyNotExist,//CD Key不存在
  30. ActivityErrorTypeNetworkDisable,//网络不可用
  31. ActivityErrorTypeOutNumber,//CD Key超出绑定数量,被其他设备使用
  32. ActivityErrorTypeCDKeyExpire,//序列码过期
  33. ActivityErrorTypeInvalidInfo,//激活错误,联系我们或查看FAQ
  34. ActivityErrorTypeNotMatchProduct,//CDkey是其他产品的
  35. ActivityErrorTypeFormatError,//格式错误
  36. ActivityErrorTypeUnknow,//未知错误
  37. }ActivityErrorType;
  38. typedef enum {
  39. ActivityStatusNone,
  40. ActivityStatusTrial, //试用
  41. ActivityStatusVerification, //激活
  42. ActivityStatusTrialExpire, //试用过期
  43. ActivityStatusVerifExpire, //过期
  44. ActivityStatusLicenseExpire,//序列号过期
  45. }ActivityStatus;
  46. typedef void(^ActivityComplention)(ActivityStatus status, NSDictionary *info, NSError *error);
  47. @interface VerificationManager : NSObject
  48. @property (nonatomic) BOOL autoVerification; //激活码定期自动校验,默认隔一小时校验一次
  49. @property (nonatomic, readonly) ActivityStatus status;
  50. @property (nonatomic, readonly) BOOL needUpgradeLicense;
  51. @property (nonatomic, readonly) NSString *licenseCode;
  52. @property (nonatomic, readonly) NSString *originLicenseCode;
  53. @property (nonatomic, readonly) NSDictionary *detailInfo;
  54. @property (nonatomic, readonly) BOOL secondTrialEnabled;
  55. @property (nonatomic, readonly) NSInteger trialTimes;
  56. @property (nonatomic, readonly) NSString *email;
  57. @property (nonatomic, readonly) NSString *subscriptionEmail;
  58. @property (nonatomic, readonly) NSString *accountName;
  59. @property (nonatomic, readonly) BOOL isVerificationCode;
  60. @property (nonatomic, readonly) BOOL showTrialGuide;
  61. @property (nonatomic, readonly) BOOL allowUnbind;
  62. @property (nonatomic, readonly) NSInteger unbindTimes;
  63. + (VerificationManager *)manager;
  64. + (VerificationManager *)defaultManager;
  65. + (NSMutableData*)mutableDataWithDic:(NSDictionary*)dic;
  66. ///** 跳转到 Built to Connect 官网商城购买界面,各App可自行跳转到对应激活购买界面
  67. // */
  68. //- (void)fetchVerificationCode;
  69. /** 激活设备
  70. @params info
  71. email 用户Email,可选
  72. cdkey 用户用于激活设备的激活码,必选
  73. */
  74. - (void)activateDeviceWithInfo:(NSDictionary*)info
  75. complention:(ActivityComplention)complention;
  76. /** 验证设备信息
  77. */
  78. - (void)verificationWithComplention:(ActivityComplention)complention;
  79. /** 提交试用
  80. @param days 申请试用天数,由App端指定,Server端会限定最大试用天数
  81. @param email option, 申请人Email信息
  82. */
  83. - (void)trialForDays:(float)days
  84. email:(NSString*)email
  85. name:(NSString*)name
  86. complention:(ActivityComplention)complention;
  87. - (void)trialForDays:(float)days
  88. complention:(ActivityComplention)complention;
  89. /** 邀请部分
  90. @param email 当前App使用的email 地址,用于接由试用体验邮件
  91. */
  92. - (void)getCodeWithEmail:(NSString*)email
  93. complention:(ActivityComplention)complention;
  94. /** 使用好友的邀请码
  95. */
  96. - (void)userCode:(NSString*)code
  97. complention:(ActivityComplention)complention;
  98. /** 修改用户email
  99. */
  100. - (void)modifyEmail:(NSString*)email
  101. complention:(ActivityComplention)complention;
  102. /** 给好友发送邀请email, 多个email 使用 , 号分隔
  103. */
  104. - (void)sendInvateEmails:(NSString*)emails
  105. code:(NSString*)code
  106. complention:(ActivityComplention)complention;
  107. - (NSString*)udid;
  108. @end
  109. #pragma mark - Data Parse
  110. @interface NSDictionary (ActivityInfo)
  111. @property (nonatomic, readonly) ActivityStatus status;
  112. @property (nonatomic, readonly) NSDate *createDate;
  113. @property (nonatomic, readonly) NSDate *expireDate;
  114. @property (nonatomic, readonly) NSString *licenseCode;
  115. @property (nonatomic, readonly) NSString *originLicenseCode;
  116. @property (nonatomic, readonly) NSString *shareCode;
  117. @property (nonatomic, readonly) NSUInteger invateUsersCount;
  118. @property (nonatomic, readonly) NSDate *fetchInvateDate;
  119. @property (nonatomic, readonly) NSString *fromCode;
  120. @property (nonatomic, readonly) NSUInteger maxFreeDays;
  121. @property (nonatomic, readonly) BOOL repeatTrial;
  122. @property (nonatomic, readonly) NSString *email;
  123. @property (nonatomic, readonly) NSString *subscriptionEmail;
  124. @property (nonatomic, readonly) NSString *accountName;
  125. @property (nonatomic, readonly) NSUInteger trialTimes;
  126. @property (nonatomic, readonly) BOOL allowUnbind;
  127. @property (nonatomic, readonly) NSInteger unbindTimes;
  128. @end
  129. #if DEBUG
  130. @interface VerificationManager (Test)
  131. - (void)updateVerificationStatus;
  132. - (void)updateStatus:(ActivityStatus)status postNo:(bool)postNo;
  133. @end
  134. #endif
  135. /// Notification
  136. extern NSString *kDeviceVerifyFinishNotification;//调用验证接口结束后发送通知
  137. extern NSString *kDeviceActivateStatusChangeNotification;