-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
88 lines (53 loc) · 1.61 KB
/
Copy pathindex.js
File metadata and controls
88 lines (53 loc) · 1.61 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Created by qiepeipei on 16/7/21.
*/
'use strict';
import React, { PropTypes, Component } from 'react';
import {
DeviceEventEmitter,
NativeModules,
Platform,
} from 'react-native'
var update = NativeModules.XunFeiUpdate;
class Update{
constructor (config) {
if(typeof config.DebugMode === 'undefined'){
config.DebugMode = false;
}
if(typeof config.NotificationType === 'undefined'){
config.NotificationType = 2;
}
if(typeof config.UpdateType === 'undefined'){
config.UpdateType = 1;
}
if(typeof config.DebugMode != 'boolean'){
throw 'DebugMode必须为bool类型';
}
if(typeof config.NotificationType != 'number'){
throw 'NotificationType必须为int类型';
}
if(typeof config.UpdateType != 'number'){
throw 'UpdateType必须为int类型';
}
if(parseInt(config.NotificationType) != config.NotificationType){
throw 'NotificationType参数有误';
}
if(parseInt(config.UpdateType) != config.UpdateType){
throw 'UpdateType参数有误';
}
this.updates = {};
//接收 socketEvent事件
this.deviceEventSubscription = DeviceEventEmitter.addListener(
'updateEvent', this._updateEvent.bind(this)
);
// 初始化socket对象
update.initialise(config);
}
_updateEvent(event){
this.updates(event);
}
updateEvent(updates){
this.updates = updates;
}
}
module.exports = Update;