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