SDK API Guide

Last updated:2021-12-15
Expand all
SDK API Guide

SDK Initialize API

  • JPushInterface. init(context,appkey:string,channel:string)
  • Interface description:
  • Initialization interface. Yes app. ux Yes. onCreate. to be used in other modules this.$app. JPushInterface by which other interface calls are made.
  • Parameter description:
  • context: Apply context
  • appkey: created and applied in the network appkey
  • channel: Channel name, default value:default-channel
  • Call Example:
this. JPushInterface=JPushInterface. init(this,"官网中创建应用后分配的appkey","自定义channel");
              this. JPushInterface=JPushInterface. init(this,"官网中创建应用后分配的appkey","自定义channel");

        
This code block is shown in the floating window
  • JPushInterface. setDebugMode(enable:boolean)
  • Interface description:
  • Settings to open debug Mode. true will print more log information. Settings false Close SDK description init Call before interface.
  • Parameter description:
  • enable: debug Switches
  • Call Example:
JPushInterface. setDebugMode(true);
              JPushInterface. setDebugMode(true);

        
This code block is shown in the floating window

Access JPush RegistrationID

  • JPushInterface. registrationID(callback: (code: number, regId: string)=>void)
  • Interface description:
  • Get delivery RegistrationID Interface
  • Parameter description:
  • callback: RegistrationID Backup + code: Error code+ regID: Send RegistrationID
  • Call Example:
this.$app. JPushInterface. registrationID((code, regID)=>{})
              this.$app. JPushInterface. registrationID((code, regID)=>{})

        
This code block is shown in the floating window

Vendor push.

  • JPushInterface. registerQuickPush(callback: (code: number, msg: string)=>void)
  • Interface description:
  • Registered manufacturer
  • Parameter description:
  • callback:
  • Returns the corresponding status code: 0 for success, 1 for which the vendor does not support delivery
this.$app. JPushInterface. registerQuickPush((code, msg)=>{})
              this.$app. JPushInterface. registerQuickPush((code, msg)=>{})

        
This code block is shown in the floating window

JPush

  • JPushInterface. subscribeJPushNotify(callback: (title:string, content: string, url: string)=>void)
  • Interface description:
  • SubscriptionsJPush;received when application is at the front desk and set up for displayJPush(Non-manufacturing) The delivery will not be displayed in the notice box, but rather will be returned to the client for distress.
  • Parameter description:
  • callback:
  • Title, Contents, Jump Link
this.$app. JPushInterface. subscribeJPushNotify((title, content, url)=>{})
              this.$app. JPushInterface. subscribeJPushNotify((title, content, url)=>{})

        
This code block is shown in the floating window

Custom message

  • JPushInterface. subscribeJPushMessage(callback: (title:string, content: string, msgid: string, extra:object)=>void)
  • Interface description:
  • Accept Custom Messages Through This Interface Push.
    SDK Customized messages are simply transmitted and will not be displayed on any interface.
  • Parameter description:
  • callback:
  • Title, content, message id, fax objects
this.$app. JPushInterface. subscribeJPushMessage((title, content, msgid, extra)=>{})
              this.$app. JPushInterface. subscribeJPushMessage((title, content, msgid, extra)=>{})

        
This code block is shown in the floating window

Tabs and aliases

  • JPushInterface. addTags(tags: [string], seq: number, callback: (code: number, tags: [string], seq: number)=>void)
  • Interface description:
  • Call this API To add labels, in callback.
  • Parameter Description: + tags + Unable to set nil Or an empty collection. NSSet set) + Pool membership type required NSString Type + Set at least one call per call tag + valid label composition: letters (case-sensitive), numbers, underlineds, Chinese characters, special characters@#$& =.| limits: each tag Name length limited to 40 bytes, with maximum support settings 1000 individual tag, but the total length shall not exceed 5 K bytes. (The length of the judgement must be used UTF-8 Encoding) + Maximum support settings for individual devices 1000 individual tag. App Global tag Maximum support settings for unlimited number of individual devices 1000 individual tag. App Global tag Unlimited + seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Parameters used for the return return tags and returns the corresponding state code: 0 for success, refer to error code definition for other returns. seq Session serial number entered for call
this.$app. JPushInterface. addTags(["1","2"], 0, (code, tags, seq)=>{})
              this.$app. JPushInterface. addTags(["1","2"], 0, (code, tags, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. setTags(tags: [string], seq: number, callback: (code: number, tags: [string], seq: number)=>void)
  • Interface description:
  • Call this API. To set the label, in callback.
    Note: This interface is to overwrite the logic, not add the logic, and calling this interface will overwrite all previously set labels
  • Parameter Description: + tags: + Unable to set nil Or an empty collection. NSSet set) + Pool membership type required NSString Type + Set at least one call per call tag + valid label composition: letters (case-sensitive), numbers, underlineds, Chinese characters, special characters@#$& =.| limits: each tag Name length limited to 40 bytes, with maximum support settings 1000 individual tag, but the total length shall not exceed 5 K bytes. (The length of the judgement must be used UTF-8 Encoding) + Maximum support settings for individual devices 1000 individual tag. App Global tag Maximum support settings for unlimited number of individual devices 1000 individual tag. App Global tag Unlimited + seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Parameters used for the return return tags and returns the corresponding state code: 0 for success, refer to error code definition for other returns. seq Session serial number entered for call
this.$app. JPushInterface. setTags(["1","2"], 0, (code, tags, seq)=>{})
              this.$app. JPushInterface. setTags(["1","2"], 0, (code, tags, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. validateTag(tag: string, seq: number, callback: (code: number, tags: [string], seq: number, isVaild:boolean)=>void)
  • Interface description:
  • Call this API To verify the target. tag description
  • Parameter Description: + tag + Unable to set nil Or empty string + valid label composition: letters (case-sensitive), numbers, underlineds, Chinese characters, special characters@#$&==.| + each tag Nam length limit to 40 bytes + seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Parameters used for the return return tags and returns the corresponding state code: 0 for success, refer to error code definition for other returns. seq is the session serial number that is entered on call. isVaild For Query tag Has it been bound?
this.$app. JPushInterface. validateTag("1", 0, (code, tags, seq, isVaild)=>{})
              this.$app. JPushInterface. validateTag("1", 0, (code, tags, seq, isVaild)=>{})

        
This code block is shown in the floating window
  • JPushInterface. deleteTags(tags: [string], seq: number, callback: (code: number, tags: [string], seq: number)=>void)
  • Interface description:
  • Call this API to remove the label, in callback.
  • Parameter Description: + tags + Unable to set nil Or an empty collection. NSSet set) + Pool membership type required NSString Type + Set at least one call per call tag + valid label composition: letters (case-sensitive), numbers, underlineds, Chinese characters, special characters@#$& =.| limits: each tag Name length limited to 40 bytes, with maximum support settings 1000 individual tag, but the total length shall not exceed 5 K bytes. (The length of the judgement must be used UTF-8 Encoding)+ seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Parameters used for the return return tags and returns the corresponding state code: 0 for success, refer to error code definition for other returns. seq Session serial number entered for call
this.$app. JPushInterface. deleteTags(["1","2"], 0, (code, tags, seq)=>{})
              this.$app. JPushInterface. deleteTags(["1","2"], 0, (code, tags, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. cleanTags(seq: number, callback: (code: number, tags: [string], seq: number)=>void)
  • Interface description:
  • Call this API to remove the label, in callback.
  • Parameter Description: + seq: + Serial number entered on request, returns as it is on call
  • callback: +Returns the corresponding state code: 0 for success, for other returns, refer to error code definition. seq The session serial number that is entered on call,tags No sense.
this.$app. JPushInterface. cleanTags(0, (code, tags, seq)=>{})
              this.$app. JPushInterface. cleanTags(0, (code, tags, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. getAllTags(seq: number, callback: (code: number, tags: [string], seq: number)=>void)
  • Interface description:
  • Call this API description
  • Parameter Description: + seq: + Serial number entered on request, returns as it is on call
  • callback: +Returns the corresponding state code: 0 for success, for other returns, refer to error code definition. seq The session serial number that is entered on call,tags All Tabs for Current Settings
this.$app. JPushInterface. getAllTags(0, (code, tags, seq)=>{})
              this.$app. JPushInterface. getAllTags(0, (code, tags, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. setAlias(alias: string, seq: number, callback: (code: number, alias: string, seq: number)=>void)
  • Interface description:
  • Call this API Set alias
  • Parameter Description: + alias + Unable to set nil Or empty string + valid label composition: letters (case-sensitive), numbers, underlineds, Chinese characters, special characters@#$&==.| + each alias Nam length limit to 40 bytes + seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Parameters used for the return return alias and returns the corresponding state code: 0 for success, refer to error code definition for other returns. seq is the session serial number that is entered on call.
this.$app. JPushInterface. setAlias("1", 0, (code, alias, seq)=>{})
              this.$app. JPushInterface. setAlias("1", 0, (code, alias, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. deleteAlias(seq: number, callback: (code: number, alias: string, seq: number)=>void)
  • Interface description:
  • Call this API To delete alias
  • Parameter Description: + seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Returns the corresponding state code: 0 for success, other returns are referred to the error code definition. seq is the session serial number that is entered on call. alias No sense.
this.$app. JPushInterface. deleteAlias(0, (code, alias, seq)=>{})
              this.$app. JPushInterface. deleteAlias(0, (code, alias, seq)=>{})

        
This code block is shown in the floating window
  • JPushInterface. getAlias(seq: number, callback: (code: number, alias: string, seq: number)=>void)
  • Interface description:
  • Call this API To get it. alias
  • Parameter Description: + seq: + Serial number entered on request, returns as it is on call
  • callback:
  • Returns the corresponding state code: 0 for success, other returns are referred to the error code definition. seq is the session serial number that is entered on call. alias For Current alias
this.$app. JPushInterface. getAlias(0, (code, alias, seq)=>{})
              this.$app. JPushInterface. getAlias(0, (code, alias, seq)=>{})

        
This code block is shown in the floating window

Stop and resume delivery services

  • JPushInterface. stopPush()
  • Interface description:
  • Stop pushing the service.
    It's been transferred. API After that,JPush The delivery service was completely stopped. Specific: + Unreceipt of tweets + JPushAll other API Call is not valid. JPushInterface. init Resume, call required resumePush Restore.
this.$app. JPushInterface. stopPush()
              this.$app. JPushInterface. stopPush()

        
This code block is shown in the floating window
  • JPushInterface. resumePush()
  • Interface description:
  • Restoring delivery services.
    Call this API After that,JPushFull resumption of work.
this.$app. JPushInterface. resumePush()
              this.$app. JPushInterface. resumePush()

        
This code block is shown in the floating window
  • JPushInterface. isPushStopped()
  • Interface description:
  • For inspection. Push Service Has it stopped? Return by Return Value
this.$app. JPushInterface. isPushStopped().then((isStoped)=>{ })
          this.$app. JPushInterface. isPushStopped().then((isStoped)=>{
})

        
This code block is shown in the floating window

Set cell number

  • JPushInterface. setMobile(mobile: string, callback: (code: number, msg: string)=>void)
  • Interface description:
  • Call this API Set your cell phone number.
  • Parameter Description: + mobile: Cell phone number. You can only start with "+" or a number, and then the contents can only contain "-" and a number, and not longer than 20. If you pass nil Or an empty string to untie the number.
  • callback:
  • Returns the corresponding state code: 0 for success, other returns are referred to the error code definition.
this.$app. JPushInterface. setMobile("11100002222", (code, msg)=>{})
              this.$app. JPushInterface. setMobile("11100002222", (code, msg)=>{})

        
This code block is shown in the floating window

Notification Click Statistics

  • JPushInterface. notificationReceive(query, callback: (param) => void)
  • Interface description:
  • Since there is no dedicated click-processing interface for fast applications, we need to add clicks to the page where they can be pushed. On the corresponding page onInit and onRefresh Adds the interface to call.
  • Parameter description:
  • query: Arguments carried while opening the page, with internal contents Jiguang Message id
  • callback: In the notification extra Rewind
onInit(query) { this.$app. JPushInterface. notificationReceive(query, (param) =>{ }) }, onRefresh(query) { this.$app. JPushInterface. notificationReceive(query, (param) =>{ }) } param为JPush透传参数
              onInit(query) {
 this.$app. JPushInterface. notificationReceive(query, (param) =>{

 })
 },
 onRefresh(query) {
 this.$app. JPushInterface. notificationReceive(query, (param) =>{

 })
 }

    param为JPush透传参数

        
This code block is shown in the floating window

Custom Message Click Statistics

  • JPushInterface. customNotificationReceive(msgid: string)
  • Interface description:
  • Developer calls this interface to report custom notifications
  • Parameter Description: + msgid: Jiguang Message id
this.$app. JPushInterface. customNotificationReceive(msgid)
              this.$app. JPushInterface. customNotificationReceive(msgid)

        
This code block is shown in the floating window

Get Current China Unicomion Status

  • JPushInterface. getChina UnicomionState()
  • Interface description:
  • Get the current connection, return the boolean type
var state = this.$app. JPushInterface. getChina UnicomionState()
              var state = this.$app. JPushInterface. getChina UnicomionState()

        
This code block is shown in the floating window

Sets the time allowed to push

  • JPushInterface. setPushTime(weekDays: Set, startHour: number, endHour: number)
  • Interface description:
  • By default, the user is allowed to send at any time. That is, whenever you push it down, the client receives it and shows it. Developer can call this API to set the time allowed for push. If you do not receive the information within that time period,SDK The treatment is that the notice of push is thrown away. This is a purely client realization, so it has nothing to do with the accuracy of the client time, time zone, etc. Furthermore, the interface is valid only for notifications and the custom message is not affected.
  • Parameter Description: + Set days 0 For Sunday, 1 for Monday, so push. (7 days)Set Gather inside. int Range 0 to 6) + set value null, and you can receive a notice at any time. set Yes. size 0 means that no notification is received at any time. + startHour Allows the start time of push (24 hours):startHour range 0 to 23 + endHour Allows the end time (24 hours):endHour range 0 to 23)
var weekDays = new Set([0]) this.$app. JPushInterface. setPushTime(weekDays, 0, 12)
           var weekDays = new Set([0])
    this.$app. JPushInterface. setPushTime(weekDays, 0, 12)

        
This code block is shown in the floating window

Client error code definition

Code Description Detailed explanation
6001 Invalid settings,tag/alias Shouldn't all be null
6002 tags/alias Timeout Interface Call Over20sNo response.
6003 alias String Invalid Valid aliases, label composition: letters (case-sensitive), numbers, underlined, Chinese
6004 aliasOverlong. Up to 40 bytes Chinese UTF-8 Yes 3 bytes
6005 Some of them. tag String Invalid Valid aliases, label composition: letters (case-sensitive), numbers, underlined, Chinese
6006 Some of them. tag Overlong. One. tag Up to 40 bytes Chinese UTF-8 Yes 3 bytes
6007 tags Quantity exceeded limit. Most 1000individual This is the limit of a device. There is no limit to the number of labels that apply to the whole world.
6008 tag Beyond the total length limit Total length up to 5K bytes
6009 Unknown error SDKThere was an unexpected anomaly.
6011 10sInternal SettingstagoraliasMore than 10 times It's operating too often in a short time.
6014 I'm asking for a favor. Request too often. Request failed. Relaunch request.
6015 Blacklist Users are blacklisted
6016 Invalid user Invalid user request failed
6017 The request is invalid. This request has an abnormal parameter. The request is invalid.
6018 TagsToo much. The usertagsSet Over1000It can't be set.
6019 AccessTagsFailed Getting AlltagsThere's been an anomaly.
6020 Request failed Special problems have caused the request to fail.
6021 tagsOperation in progress Last time. tagsThe request is still pending.
6022 aliasOperation in progress Last time. aliasThe request is still pending.
Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center