-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDevice.swift
33 lines (30 loc) · 1.04 KB
/
Device.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// Device.swift
// BlackHawk
//
// Created by leqicheng on 15/8/30.
// Copyright © 2015年 乐其橙科技(北京)有限公司. All rights reserved.
//
import WebKit
class Device {
static func injectValuesInToRuntime(wk: WKWebView) {
let cordova = "BlackHawk 0.1"
var systemInfo = utsname()
uname(&systemInfo)
let mirror = Mirror(reflecting: systemInfo.machine)
var identifier = String()
for i in mirror.children
{
let value = i.value as? Int8
if (value != nil && value != 0)
{
identifier.append(UnicodeScalar(UInt8(value!)))
}
}
let model = identifier
let platform = "iOS"
let uuid = UIDevice.currentDevice().identifierForVendor!.UUIDString
let version = UIDevice.currentDevice().systemVersion
wk.evaluateJavaScript("device={cordova: '\(cordova)', model: '\(model)', platform: '\(platform)', uuid: '\(uuid)', version: '\(version)'}", completionHandler: nil)
}
}