Demo地址: https://github.com/Initial-C/LimitingProgram
注意!!!
This item is used only for application settings permissions, third-party application user can only be used within a valid time, after the expiration of time application will prompt the user for authorization, and exit the program, note: the last App you cannot use this method, otherwise it will be Apple's Audit Department refused
該項目僅用于給應(yīng)用設(shè)置權(quán)限, 讓第三方用戶只能在有效時間內(nèi)使用應(yīng)用, 時間到期后應(yīng)用會提示用戶進行授權(quán), 并且退出程序, 注意: 上架的App不能使用本方法, 否則會被蘋果審核部門拒絕
由于公司給甲方的測試產(chǎn)品需要進行權(quán)限設(shè)置(目的防止甲方毀約, 直接拿測試產(chǎn)品分發(fā)使用)
具體思路很簡單:?
1. 直接在AppDelegate中BecomeActive代理方法里面添加exit方法即可
2. 實現(xiàn)邏輯相對簡單, 權(quán)限的邏輯即判斷是否過期, 所以為了防止用戶更改本地時間從而"破解"使用權(quán)限, 這里的方案是添加使用網(wǎng)絡(luò)時間作為參考時間
3. 麻煩的是時間的轉(zhuǎn)換, 特別是網(wǎng)絡(luò)時間的獲取和格式化轉(zhuǎn)換, 為了方便使用, 已將獲取網(wǎng)絡(luò)時間方法封裝成工具類
4. 效果:?
