APDID.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // APDID.h
  3. // APPSecuritySDK
  4. //
  5. // Created by eric on 2021/2/7.
  6. // Copyright © 2021 Alipay. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "ASSTokenResult.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. typedef void(^ASSSecureSdkCallback)(ASSTokenResult* result, NSString* error);
  12. typedef void(^ASSSecureSdkOpenCallback)(NSString* token, int errorCode);
  13. @interface APDID : NSObject
  14. /*
  15. 异步初始化vkeyid,推荐在app启动时和收银台页面加载时调用,SDK内部会根据时间戳和设备信息进行判断是否需要进行网络请求,无线程要求
  16. @param params 初始化的字典参数,包含三项内容:tid、userid、environment;
  17. tid与userid选传,传入可以保证vkeyid与其正确关联,取不到传入空字符串;
  18. 环境变量请与app设置中的环境相关联,字典中的value包括线上,预发,测试,日常;
  19. @param callback 初始化完成后的结果回调
  20. Asynchronously initialize vkeyid(apdid), recommend to invoke this API when app launches, and cashier view presents.
  21. Inside SDK we will decide whether to launch network request or not based on timestamp and device info.
  22. No thread requirement.
  23. @param params: Initialized parameters, includes 3 key-value pairs: tid, userid,environment;
  24. Tid and userid are optional, they can be associated with vkeyid(apdid) if passed in.
  25. If the values for tid and userid are not available, pass in empty NSString(@"").
  26. @param callback: Callback block when token is available
  27. */
  28. + (void) initToken:(NSDictionary*)params callback:(ASSSecureSdkCallback)callback;
  29. /*
  30. 同步获取vkeyid完整信息,包括vkeyid,token,clientkey,无网络请求;
  31. 如果首次安装app,且首次网络请求未完成或失败,将会返回降级措施:vkeyid会返回客户端随机串clientkey,token将会返回空。
  32. Synchronously get full info of vkeyid(apdid), token and clientkey, no network requests.
  33. If the app is installed for the first time and first network request failed, it would return degradation result: vkeyid would be clientkey which is a client-side generated random string, token would be empty NSString @""
  34. */
  35. + (ASSTokenResult*)getToken DEPRECATED_MSG_ATTRIBUTE("use getTokenResult instead");
  36. /*
  37. 同步获取vkeyid完整信息,包括vkeyid,token,clientkey,无网络请求;
  38. 如果首次安装app,且首次网络请求未完成或失败,将会返回降级措施:vkeyid会返回客户端随机串clientkey,token将会返回空。
  39. Synchronously get full info of vkeyid(apdid), token and clientkey, no network requests.
  40. If the app is installed for the first time and first network request failed, it would return degradation result: vkeyid would be clientkey which is a client-side generated random string, token would be empty NSString @""
  41. */
  42. + (ASSTokenResult*)getTokenResult;
  43. + (ASSTokenResult *)getTokenResult:(NSString*)appName appKeyClient:(NSString*)appKeyClient;
  44. //===================lazada api====================//
  45. /*
  46. 异步初始化vkeyid,推荐在app启动时和收银台页面加载时调用,SDK内部会根据时间戳和设备信息进行判断是否需要进行网络请求,无线程要求
  47. @param appName 应用名称
  48. @param appKeyClient 应用客户端密钥
  49. @param callback 初始化完成后的结果回调,以Token作为参数
  50. */
  51. + (void)initToken:(NSString *)appName appKeyClient:(NSString *)appKeyClient callback:(ASSSecureSdkOpenCallback)callback;
  52. /*
  53. 同步接口返回token
  54. @param appName 应用名称
  55. @param appKeyClient 应用客户端密钥
  56. */
  57. + (NSString *)getResultToken;
  58. /*
  59. 同步接口返回token
  60. @param appName 应用名称
  61. @param appKeyClient 应用客户端密钥
  62. */
  63. + (NSString *)getResultToken:(NSString*)appName appKeyClient:(NSString*)appKeyClient;
  64. //===================TMN api====================//
  65. /*
  66. 异步初始化vkeyid,推荐在app启动时和收银台页面加载时调用,SDK内部会根据时间戳和设备信息进行判断是否需要进行网络请求,无线程要求
  67. @param appName 应用名称
  68. @param appKeyClient 应用客户端密钥
  69. @param sessionId 业务方传入自己的id
  70. @param callback 初始化完成后的结果回调,以Token作为参数
  71. */
  72. + (void)initToken:(NSString *)appName appKeyClient:(NSString *)appKeyClient sessionId:(NSString *)sessionId callback:(ASSSecureSdkOpenCallback)callback;
  73. //===================ae api====================//
  74. /*
  75. 强制上报接口
  76. @param params 初始化的字典参数,包含四项内容:umid、tid、userid、environment;
  77. umid必传,tid与userid选传,传入可以保证vkeyid与其正确关联,取不到传入空字符串;
  78. 环境变量请与app设置中的环境相关联,字典中的value包括线上,预发,测试,日常;
  79. @param callback 初始化完成后的结果回调
  80. */
  81. + (void) updateToken:(NSDictionary*)params callback:(ASSSecureSdkCallback)callback;
  82. @end
  83. NS_ASSUME_NONNULL_END