Interroger le système (sys.mgcopyanswer)
Déclaration
réponse = sys.mgcopyanswer(question)
Paramètres
- question — Texte, nom de la question ; consultez MobileGestalt.h.
Valeur de retour
- réponse — Chaîne, table, nombre réel, entier, booléen ou
nil; réponse du système, ounilsi la question n’est pas prise en charge.
Description
Obtient des informations système via MGCopyAnswer. Mots-clés : informations système, informations de l’appareil, identifiant de l’appareil, numéro de téléphone
Exemple
sys.alert("设备的序列号是:"..sys.mgcopyanswer("SerialNumber"))
sys.alert("设备的 IMEI 是:"..sys.mgcopyanswer("InternationalMobileEquipmentIdentity"))
sys.alert("设备的 MEID 是:"..sys.mgcopyanswer("MobileEquipmentIdentifier"))
sys.alert(string.format('设备的 ECID 是:%016X', sys.mgcopyanswer('UniqueChipID')))
local infos = sys.mgcopyanswer('CarrierBundleInfoArray')
if type(infos) == 'table' and #infos > 0 then
local info = infos[1]
if type(info.InternationalMobileSubscriberIdentity) == 'string' then
sys.alert("运营商 IMSI 是:"..info.InternationalMobileSubscriberIdentity)
else
sys.alert("无法读取运营商 IMSI,请确认设备已正确插入 SIM 卡")
end
if type(info.IntegratedCircuitCardIdentity) == 'string' then
sys.alert("运营商 ICCID 是:"..info.IntegratedCircuitCardIdentity)
else
sys.alert("无法读取运营商 ICCID,请确认设备已正确插入 SIM 卡")
end
else
sys.alert("无法读取运营商信息,请确认设备已正确插入 SIM 卡")
end
local phone_number = sys.mgcopyanswer('PhoneNumber')
if sys.mgcopyanswer('SIMTrayStatus') == 'kCTSIMSupportSIMTrayInsertedWithSIM' and type(phone_number) == 'string' then
sys.alert("手机号是:"..phone_number)
else
sys.alert("无法读取手机号,请确认设备已正确插入 SIM 卡")
end