localdeviceservice=registry.getService("device")
fork,vinpairs(deviceservice) doprint(k,v)
endwhiletruedoprint(deviceservice.batteryLevel) -- [16:18:27.236] 0.89999997615814print(deviceservice.wlan) -- [16:18:27.242] trueprint(deviceservice.userAgent) -- [16:18:27.243] Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D167 MaryKayMobility/1.2.0deviceservice.flashlight=notdeviceservice.flashlightdeviceservice.statusBarHidden=notdeviceservice.statusBarHiddendeviceservice:vibrate()
sleep(5)
deviceservice:playSoundFile("tap.aif")
sleep(5)
end--[[[16:18:27.223] os.version 7.1[16:18:27.224] modelId iPhone4,1[16:18:27.224] framework.version 1.2.0[16:18:27.224] locale zh_CN[16:18:27.224] macaddress 02:00:00:00:00:00[16:18:27.224] manufacturer Apple[16:18:27.224] language zh-Hans[16:18:27.225] identifier A27997B2-9B8D-46C8-BEDD-825017A58A72[16:18:27.225] __id__ userdata: 0x165f9854[16:18:27.225] os.name IOS[16:18:27.225] retina true[16:18:27.225] uuid A27997B2-9B8D-46C8-BEDD-825017A58A72[16:18:27.225] type Mobile[16:18:27.225] model iPhone 4S[16:18:27.225] resolutionHeight 460[16:18:27.226] resolutionWidth 320[16:18:27.226] networkType WCDMA[16:18:27.226] framework.name com.marykay.china.mobilityApp[16:18:27.236] 0.89999997615814[16:18:27.242] true[16:18:27.243] Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D167 MaryKayMobility/1.2.0]]
localnotification
locallocalnotificationservice=registry.getService("localnotification")
localnotificationservice:clear() -- remove all if required.localnotificationservice:add{
sound=localnotificationservice.defaultSound,
title="You have a new message.",
action="ClickMe",
datetime=os.time() +10, -- 10s laterbody= {id="0001"} -- any table map.
}
localEvent=require"framework.event"localjson=require"json"Event.gbind(Event.PUSH_NOTIFICATION, function(e)
print(json.encode(e.body))
end)
locale
------------------------------------------------------
use locale directly, e.g.
```lua
local locale = registry.getService("locale")
print(locale["some.locale.key"])
```
email
------------------------------------------------------
```lua
local contactsService = registry.getService("contacts")
local watcher = contactsService:addChangeWatcher(function(...)
print(...)
end)
contactsService:load(function(cs, success)
print(cs, success)
for i,v in ipairs(cs.all) do
for i2,v2 in pairs(v) do
print(i2,v2)
end
print(i,v.fullName, json.encode(v.phones))
end
end)
```
image
------------------------------------------------------
```lua
local photoservice = registry.getService("photo")
photoservice:load(function(groups)
for k,group in pairs(groups) do
print(group.name, group.type)
for i,v in ipairs(group.photos) do
print(i,v) -- v is kind of LuaImage
end
end
end)
```
Open APIs
======================================================
[sqlite3](http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki)
[sqlcipher](http://sqlcipher.net/sqlcipher-api/)
[lua sqlite3](http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki)
Push
localutils=require"framework.utils"localbase=require"framework.base"localEvent=require"framework.event"Event.gbind(Event.PUSH_TOKEN_UPDATED, function(e)
print(e.token) -- nil on failend)
Event.gbind(Event.PUSH_NOTIFICATION, function(e)
print(e.alert, e.badge, e.body)
print(base.getGSandbox():get("notification_data")) -- any place you want after app launch.base.getGSandbox():put("notification_data", nil) -- clear dataend)
utils.requestPushToken()