@@ -80,149 +80,146 @@ export default class App extends Component {
8080 } )
8181 }
8282
83- setTag ( ) {
84- if ( this . state . tag !== undefined ) {
85- // 请注意这个接口要传一个数组过去,这里只是个简单的示范
86- JPushModule . setTags ( this . state . tag . split ( ',' ) , map => {
87- if ( map . errorCode === 0 ) {
88- console . log ( 'Tag operate succeed, tags: ' + map . tags )
89- } else {
90- console . log ( 'error code: ' + map . errorCode )
91- }
92- } )
93- }
94- }
95-
96- addTag = ( ) => {
97- console . log ( 'Adding tag: ' + this . state . tag )
98- JPushModule . addTags ( this . state . tag . split ( ',' ) , map => {
99- if ( map . errorCode === 0 ) {
100- console . log ( 'Add tags succeed, tags: ' + map . tags )
101- } else {
102- console . log ( 'Add tags failed, error code: ' + map . errorCode )
103- }
104- } )
105- }
106-
107- deleteTags = ( ) => {
108- console . log ( 'Deleting tag: ' + this . state . tag )
109- JPushModule . deleteTags ( this . state . tag . split ( ',' ) , map => {
110- if ( map . errorCode === 0 ) {
111- console . log ( 'Delete tags succeed, tags: ' + map . tags )
112- } else {
113- console . log ( 'Delete tags failed, error code: ' + map . errorCode )
114- }
115- } )
116- }
117-
118- checkTag = ( ) => {
119- console . log ( 'Checking tag bind state, tag: ' + this . state . tag )
120- JPushModule . checkTagBindState ( this . state . tag , map => {
121- if ( map . errorCode === 0 ) {
122- console . log (
123- 'Checking tag bind state, tag: ' +
124- map . tag +
125- ' bindState: ' +
126- map . bindState
127- )
128- } else {
129- console . log (
130- 'Checking tag bind state failed, error code: ' + map . errorCode
131- )
132- }
133- } )
134- }
135-
136- getAllTags = ( ) => {
137- JPushModule . getAllTags ( map => {
138- if ( map . errorCode === 0 ) {
139- console . log ( 'Get all tags succeed, tags: ' + map . tags )
140- } else {
141- console . log ( 'Get all tags failed, errorCode: ' + map . errorCode )
142- }
143- } )
144- }
145-
146- cleanTags = ( ) => {
147- JPushModule . cleanTags ( map => {
148- if ( map . errorCode === 0 ) {
149- console . log ( 'Clean all tags succeed' )
150- } else {
151- console . log ( 'Clean all tags failed, errorCode: ' + map . errorCode )
152- }
153- } )
154- }
155-
156- setAlias ( ) {
157- if ( this . state . alias !== undefined ) {
158- JPushModule . setAlias ( this . state . alias , map => {
159- if ( map . errorCode === 0 ) {
160- console . log ( 'set alias succeed' )
161- } else {
162- console . log ( 'set alias failed, errorCode: ' + map . errorCode )
163- }
164- } )
165- }
166- }
167-
168- deleteAlias = ( ) => {
169- console . log ( 'Deleting alias' )
170- JPushModule . deleteAlias ( map => {
171- if ( map . errorCode === 0 ) {
172- console . log ( 'delete alias succeed' )
173- } else {
174- console . log ( 'delete alias failed, errorCode: ' + map . errorCode )
175- }
176- } )
177- }
178-
179- getAlias = ( ) => {
180- JPushModule . getAlias ( map => {
181- if ( map . errorCode === 0 ) {
182- console . log ( 'Get alias succeed, alias: ' + map . alias )
183- } else {
184- console . log ( 'Get alias failed, errorCode: ' + map . errorCode )
185- }
186- } )
187- }
188-
189- setBaseStyle ( ) {
190- if ( Platform . OS === 'android' ) {
191- JPushModule . setStyleBasic ( )
192- } else {
193- Alert . alert ( 'iOS not support this function' , '' )
194- }
195- }
196-
197- setCustomStyle ( ) {
198- if ( Platform . OS === 'android' ) {
199- JPushModule . setStyleCustom ( )
200- } else {
201- Alert . alert ( 'iOS not support this function' , '' )
202- }
203- }
204-
205- componentWillMount ( ) { }
206-
207- componentDidMount ( ) {
208- if ( Platform . OS === 'android' ) {
209- JPushModule . initPush ( )
210- JPushModule . getInfo ( map => {
211- this . setState ( {
212- appkey : map . myAppKey ,
213- imei : map . myImei ,
214- package : map . myPackageName ,
215- deviceId : map . myDeviceId ,
216- version : map . myVersion
217- } )
218- } )
219- JPushModule . notifyJSDidLoad ( resultCode => {
220- if ( resultCode === 0 ) {
221- }
222- } )
223- }
22483
225- JPushModule . addReceiveCustomMsgListener ( map => {
84+ setTag ( ) {
85+ if ( this . state . tag !== undefined ) {
86+ /*
87+ * 请注意这个接口要传一个数组过去,这里只是个简单的示范
88+ */
89+ JPushModule . setTags ( this . state . tag . split ( "," ) , ( map ) => {
90+ if ( map . errorCode === 0 ) {
91+ console . log ( "Tag operate succeed, tags: " + map . tags ) ;
92+ } else {
93+ console . log ( "error code: " + map . errorCode ) ;
94+ }
95+ } ) ;
96+ }
97+ }
98+
99+ addTag = ( ) => {
100+ console . log ( "Adding tag: " + this . state . tag ) ;
101+ JPushModule . addTags ( this . state . tag . split ( "," ) , ( map ) => {
102+ if ( map . errorCode === 0 ) {
103+ console . log ( "Add tags succeed, tags: " + map . tags ) ;
104+ } else {
105+ console . log ( "Add tags failed, error code: " + map . errorCode ) ;
106+ }
107+ } ) ;
108+ }
109+
110+ deleteTags = ( ) => {
111+ console . log ( "Deleting tag: " + this . state . tag ) ;
112+ JPushModule . deleteTags ( this . state . tag . split ( "," ) , ( map ) => {
113+ if ( map . errorCode === 0 ) {
114+ console . log ( "Delete tags succeed, tags: " + map . tags ) ;
115+ } else {
116+ console . log ( "Delete tags failed, error code: " + map . errorCode ) ;
117+ }
118+ } ) ;
119+ }
120+
121+ checkTag = ( ) => {
122+ console . log ( "Checking tag bind state, tag: " + this . state . tag ) ;
123+ JPushModule . checkTagBindState ( this . state . tag , ( map ) => {
124+ if ( map . errorCode === 0 ) {
125+ console . log ( "Checking tag bind state, tag: " + map . tag + " bindState: " + map . bindState ) ;
126+ } else {
127+ console . log ( "Checking tag bind state failed, error code: " + map . errorCode ) ;
128+ }
129+ } ) ;
130+ }
131+
132+ getAllTags = ( ) => {
133+ JPushModule . getAllTags ( ( map ) => {
134+ if ( map . errorCode === 0 ) {
135+ console . log ( "Get all tags succeed, tags: " + map . tags ) ;
136+ } else {
137+ console . log ( "Get all tags failed, errorCode: " + map . errorCode ) ;
138+ }
139+ } ) ;
140+ }
141+
142+ cleanAllTags = ( ) => {
143+ JPushModule . cleanTags ( ( map ) => {
144+ if ( map . errorCode === 0 ) {
145+ console . log ( "Clean all tags succeed" ) ;
146+ } else {
147+ console . log ( "Clean all tags failed, errorCode: " + map . errorCode ) ;
148+ }
149+ } ) ;
150+ }
151+
152+
153+ setAlias ( ) {
154+ if ( this . state . alias !== undefined ) {
155+ JPushModule . setAlias ( this . state . alias , ( map ) => {
156+ if ( map . errorCode === 0 ) {
157+ console . log ( "set alias succeed" ) ;
158+ } else {
159+ console . log ( "set alias failed, errorCode: " + map . errorCode ) ;
160+ }
161+ } ) ;
162+ }
163+ }
164+
165+ deleteAlias = ( ) => {
166+ console . log ( "Deleting alias" ) ;
167+ JPushModule . deleteAlias ( ( map ) => {
168+ if ( map . errorCode === 0 ) {
169+ console . log ( "delete alias succeed" ) ;
170+ } else {
171+ console . log ( "delete alias failed, errorCode: " + map . errorCode ) ;
172+ }
173+ } )
174+ }
175+
176+ getAlias = ( ) => {
177+ JPushModule . getAlias ( ( map ) => {
178+ if ( map . errorCode === 0 ) {
179+ console . log ( "Get alias succeed, alias: " + map . alias ) ;
180+ } else {
181+ console . log ( "Get alias failed, errorCode: " + map . errorCode ) ;
182+ }
183+ } ) ;
184+ }
185+
186+ setBaseStyle ( ) {
187+ if ( Platform . OS === 'android' ) {
188+ JPushModule . setStyleBasic ( ) ;
189+ } else {
190+ Alert . alert ( 'iOS not support this function' , '' )
191+ }
192+ }
193+
194+ setCustomStyle ( ) {
195+ if ( Platform . OS === 'android' ) {
196+ JPushModule . setStyleCustom ( ) ;
197+ } else {
198+ Alert . alert ( 'iOS not support this function' , '' )
199+ }
200+
201+ }
202+
203+ componentWillMount ( ) { }
204+
205+ componentDidMount ( ) {
206+ if ( Platform . OS === 'android' ) {
207+ JPushModule . initPush ( ) ;
208+ JPushModule . getInfo ( ( map ) => {
209+ this . setState ( {
210+ appkey : map . myAppKey ,
211+ imei : map . myImei ,
212+ package : map . myPackageName ,
213+ deviceId : map . myDeviceId ,
214+ version : map . myVersion
215+ } ) ;
216+ } ) ;
217+ JPushModule . notifyJSDidLoad ( ( resultCode ) => {
218+ if ( resultCode === 0 ) { }
219+ } ) ;
220+ }
221+
222+ JPushModule . addReceiveCustomMsgListener ( ( map ) => {
226223 this . setState ( {
227224 pushMsg : map . message
228225 } )
0 commit comments