### Platform Selection Examples Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push Examples for setting the target platform for a push notification. ```json {"platform" : "all"} ``` ```json {"platform" : ["android", "ios","quickapp","hmos"] } ``` -------------------------------- ### HTTP Request Example Source: https://docs.jiguang.cn/jportrait/server/rest_api_tag Demonstrates the GET request to the /value-added/iaudiences/tags endpoint. ```http GET /value-added/iaudiences/tags ``` -------------------------------- ### Request Example with Options and Callback Source: https://docs.jiguang.cn/jums/server/rest_api_jums_template_message An example demonstrating how to structure a request body that includes both optional parameters and callback configurations. ```APIDOC ### Request Example ```json { "aud_userid": ["user1","user2"], "msg_app": [{"platform":"android", "notification":{"android":{"alert":"Hi,JPush !"}} }], "rule_id": 1001, "option": { "sendno": "test", "owner":"admin", "black_id":1234, "priority":2 }, "callback": { "url":"https://www.jiguang.cn/ums-portal", "params":{ "name":"joe", "age":26 } } } ``` ``` -------------------------------- ### Broadcast Push Example Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push Example of sending a push notification to all devices. ```json { "platform": "all", "audience" : "all", "notification" : { "alert" : "Hi, JPush!", "android" : { "alert" : "Hi, JPush!" }, "ios" : { "extras" : { "newsid" : 321 } } } } ``` -------------------------------- ### GET /isSetupClient Source: https://docs.jiguang.cn/jverification/client/ios_api Checks if the SDK initialization was successful. ```APIDOC ## + (BOOL)isSetupClient ### Description Checks if the SDK has been successfully initialized. ### Response #### Success Response (200) - **result** (BOOL) - YES if initialized successfully, NO otherwise. ``` -------------------------------- ### Example: HarmonyOS Live Window Message (Flight Scenario) Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push Example JSON payload for sending a HarmonyOS live window message, specifically for a flight status update. ```APIDOC ## POST /api/v1/push ### Description Send a HarmonyOS live window message for flight status updates. ### Method POST ### Endpoint /api/v1/push ### Request Body - **notification** (object) - Required - Contains notification specific settings. - **hmos** (object) - Required - HarmonyOS specific notification settings. - **push_type** (integer) - Required - Type of push, set to 7 for live window messages. - **hm_payload** (object) - Required for `push_type=7` - Payload for live window messages. - **activityId** (integer) - ID of the activity. - **operation** (integer) - Operation type. - **event** (string) - The event type (e.g., 'FLIGHT'). - **status** (string) - The status of the event (e.g., 'DEPART'). - **activityData** (object) - Data related to the activity. - **notificationData** (object) - Data for the notification content. - **keywords** (object) - Keywords for dynamic content. - **flightNo** (string) - Flight number. - **type** (integer) - Type of notification data. - **contentTitle** (string) - Title of the notification content. - **contentText** (array of objects) - Text content of the notification. - **text** (string) - The text string. - **foregroundColor** (string) - Text color. - **clickAction** (object) - Action to perform on click. - **actionType** (integer) - Type of action. - **action** (string) - The action URL or command. - **firstTextBlock** (object) - First text block for display. - **firstLine** (string) - First line of text. - **secondLine** (string) - Second line of text. - **lastTextBlock** (object) - Last text block for display. - **firstLine** (string) - First line of text. - **secondLine** (string) - Second line of text. - **displayHorizontalLine** (boolean) - Whether to display a horizontal line. - **spaceIcon** (string) - Name of the space icon file in `/resources/rawfile`. - **extend** (object) - Extended content. - **type** (integer) - Type of extension. - **pic** (string) - Name of the extension picture file in `/resources/rawfile`. - **clickAction** (object) - Click action for the extension. - **actionType** (integer) - Type of action. - **action** (string) - The action URL or command. - **capsuleData** (object) - Data for the capsule UI element. - **type** (integer) - Type of capsule. - **status** (integer) - Status of the capsule. - **icon** (string) - Name of the capsule icon file in `/resources/rawfile`. - **bgColor** (string) - Background color of the capsule. - **remind** (string) - Reminder type. - **title** (string) - Title of the capsule. ### Request Example ```json { "notification" : { "hmos" : { "push_type":7, "hm_payload": { "activityId": 1, "operation": 0, "event": "FLIGHT", "status": "DEPART", // 计划出发 "activityData": { "notificationData": { "keywords": { "flightNo": "MU1471" }, "type": 5, "contentTitle": "航班{{status}}", // 航班计划出发 "contentText": [ { "text": "航班号:" }, { "text": "{{flightNo}}", // MU1471 "foregroundColor": "#FF317AF7" } ], "clickAction": { "actionType": 0 }, "firstTextBlock": { "firstLine": "12:00", "secondLine": "上海虹桥" }, "lastTextBlock": { "firstLine": "14:20", "secondLine": "成都天府" }, "displayHorizontalLine": true, "spaceIcon": "space.png", // 取值为“/resources/rawfile”路径下的文件名 "extend": { "type": 3, "pic": "flight.png", // 取值为“/resources/rawfile”路径下的文件名 "clickAction": { "actionType": 1, "action": "xxxxxxx" } } }, "capsuleData": { "type": 1, "status": 1, "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名 "bgColor": "#FF317AF7", "remind": "EXPAND", "title": "即将出发", ``` ``` -------------------------------- ### Example: Specifying HarmonyOS Platform Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push Example JSON payload to specify that notifications should be sent to the HarmonyOS platform. ```APIDOC ## POST /api/v1/push ### Description Send push notifications to specified platforms. ### Method POST ### Endpoint /api/v1/push ### Request Body - **platform** (array of strings) - Required - The target platform(s) for the push notification. ### Request Example ```json { "platform" : ["hmos"] } ``` ``` -------------------------------- ### Start Business Operations Source: https://docs.jiguang.cn/public_service/client/iOS/sdk_api Starts the behavior analysis and user profiling features. This must be called after initializing the SDK and before calling other operation-related interfaces. ```APIDOC ## Start Business Operations ### Description Starts the behavior analysis and user profiling features. This must be called after initializing the SDK and before calling other operation-related interfaces. ### Method `+ operationStart:(JOPERATEConfig * )config` ### Endpoint N/A (SDK Method) ### Parameters #### Request Body - **config** (JOPERATEConfig) - Required - Configuration object. - **appKey** (NSString) - Your application's key. - **advertisingId** (NSString) - The device's advertising identifier. ### Request Example ```objective-c JOPERATEConfig *config = [[JOPERATEConfig alloc] init]; config.appKey = @"your appkey"; config.advertisingId = idfaStr; [JOPERATEService operationStart:config]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### Start Operation Analysis (iOS) Source: https://docs.jiguang.cn/public_service/client/iOS/sdk_api Starts behavior analysis and user profiling. This must be called before other operation-related interfaces. Ensure SDK is initialized first. ```objective-c JOPERATEConfig *config = [[JOPERATEConfig alloc] init]; config.appKey = @"your appkey"; config.advertisingId = idfaStr; [JOPERATEService operationStart:config]; ``` -------------------------------- ### Get Silence Start Time Source: https://docs.jiguang.cn/jmessage/client/im_android_api_docs/cn/jpush/im/android/api/model/SilenceInfo.html Retrieves the start timestamp of the silence period in milliseconds. ```java public long getSilenceStartTime() ``` -------------------------------- ### POST /setupWithConfig Source: https://docs.jiguang.cn/jverification/client/ios_api Initializes the SDK with the provided configuration. ```APIDOC ## + setupWithConfig:(JVAuthConfig *)config ### Description Initializes the SDK using the JVAuthConfig configuration object. ### Parameters #### Request Body - **config** (JVAuthConfig) - Required - Configuration object containing appKey and other settings. ``` -------------------------------- ### Curl Request Example Source: https://docs.jiguang.cn/jportrait/server/rest_api_tag Example of how to call the Get User Tags List API using curl, including necessary headers and parameters. ```curl curl --insecure -X GET -H 'Content-Type:application/json' -H 'Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==' https://portrait-api.jiguang.cn/iaudience/open/value-added/iaudiences/tags?rid=xxxxxxxxxxx ``` -------------------------------- ### 注册一链拉起和场景还原参数回调 Source: https://docs.jiguang.cn/jmlink/client/iOS/ios_guide 在 didFinishLaunchingWithOptions 中注册通用的参数回调方法,用于接收一链拉起和场景还原功能传递的参数。 ```objective-c - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // SDK初始化 ··· // 注册通用的的获取参数回调方法 [JMLinkService registerHandler:^(JMLinkResponse * _Nullable respone) { dispatch_async(dispatch_get_main_queue(), ^{ // 拿到参数后,根据自身项目参数协议解析,处理跳转逻辑 }); }]; } ``` -------------------------------- ### JPUSHService setupWithOption Source: https://docs.jiguang.cn/jpush/client/iOS/ios_guide_new Initializes the JPush service. This method should be called in didFinishLaunchingWithOptions to start the push service and collect necessary user information. ```APIDOC ## [METHOD] [JPUSHService setupWithOption] ### Description Initializes the JPush service and enables push functionality. ### Parameters #### Request Body - **launchOptions** (NSDictionary) - Required - The launch options dictionary from didFinishLaunchingWithOptions. - **appKey** (NSString) - Required - The appKey obtained from the JPush console. - **channel** (NSString) - Required - The distribution channel of the application. - **apsForProduction** (BOOL) - Required - Specifies the APNs environment (0 for development, 1 for production). - **advertisingIdentifier** (NSString) - Optional - The IDFA string if IDFA functionality is enabled. ``` -------------------------------- ### Get Scheduled Task Details Source: https://docs.jiguang.cn/jpush/server/push/rest_api_push_schedule Endpoint and request/response examples for retrieving details of a specific scheduled task. ```http GET https://api.jpush.cn/v3/schedules/{schedule_id} ``` ```http GET /v3/schedules/{schedule_id} Authorization: Basic (base64 auth string) Content-Type: application/json Accept: application/json ``` ```http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 ``` ```json { "schedule_id":"0eac1b80-c2ac-4b69-948b-c65b34b96512" "name": "定时推送示例", "enabled": true, "trigger": { ... }, "push": { ... } } ``` -------------------------------- ### Get SDK Version Source: https://docs.jiguang.cn/public_service/client/Android/sdk_api Retrieves the current version number of the SDK. Available starting from SDK version 2.0.0. ```APIDOC ## Get SDK Version ### Description Retrieves the current version number of the SDK. Available starting from SDK version 2.0.0. ### Method `getVersion()` ### Endpoint `JOperateInterface.getInstance(getApplicationContext()).getVersion()` ### Request Example ```java JOperateInterface.getInstance(getApplicationContext()).getVersion(); ``` ### Response Returns the SDK version as a String. ``` -------------------------------- ### Get Scheduled Task Message IDs Source: https://docs.jiguang.cn/jpush/server/push/rest_api_push_schedule Endpoint and request example for retrieving all message IDs associated with a specific schedule. ```http GET https://api.jpush.cn/v3/schedules/{schedule_id}/msg_ids ``` ```http GET /v3/schedules/{schedule_id}/msg_ids Authorization: Basic (base64 auth string) Content-Type: application/json Accept: application/json ``` -------------------------------- ### Initialize Web SDK Source: https://docs.jiguang.cn/public_service/client/Web/sdk_api Initializes the SDK with the required application key and configuration settings. ```javascript window.JOperateInterface.init({ appKey: "9f7248bf870ddec7048e6c0b", // 极光官网中创建应用后分配的 appkey,必填 debugMode: true,// 设置是否开启 debug 模式。true 则会打印更多的日志信息。设置 false 则只会输出 w、e 级别的日志 channel: "default-channel",// 渠道名称,默认值为:default-channel }) ``` -------------------------------- ### Example: Create Local Notification Source: https://docs.jiguang.cn/jpush/client/Android/android_api Demonstrates how to construct and add a local notification. ```java JPushLocalNotification ln = new JPushLocalNotification(); ln.setBuilderId(0); ln.setContent("hhh"); ln.setTitle("ln"); ln.setNotificationId(11111111) ; ln.setBroadcastTime(System.currentTimeMillis() + 1000 * 60 * 10); //分类处理 5.2.0 版本开始支持 ln.setCategory(Notification.CATEGORY_ALARM); ln.setPriority(Notification.PRIORITY_DEFAULT); //PRIORITY与IMPORTANCE 相互转换关系 //PRIORITY_MIN = -2 对应 IMPORTANCE_MIN = 1; //PRIORITY_LOW = -1; 对应 IMPORTANCE_LOW = 2; //PRIORITY_DEFAULT = 0; 对应 IMPORTANCE_DEFAULT = 3; //PRIORITY_HIGH = 1; 对应 IMPORTANCE_HIGH = 4; // PRIORITY_MAX = 2; 对应 IMPORTANCE_MAX = 5; //分类处理 Map map = new HashMap() ; map.put("name", "jpush") ; map.put("test", "111") ; JSONObject json = new JSONObject(map) ; ln.setExtras(json.toString()) ; JPushInterface.addLocalNotification(getApplicationContext(), ln); ``` -------------------------------- ### GET /user/app-behavior-metrics Source: https://docs.jiguang.cn/jportrait/server/rest_api_tag Retrieves the normalized counts of applications installed or uninstalled by a user across various categories over the last three months. ```APIDOC ## GET /user/app-behavior-metrics ### Description Returns a comprehensive list of normalized metrics (0-1) representing the user's app installation and uninstallation history for the past 90 days. ### Method GET ### Endpoint /user/app-behavior-metrics ### Response #### Success Response (200) - **HII_READ_ENCYCLOPEDIA_QA** (float) - Normalized count of encyclopedia QA apps installed. - **HII_OB_ALL** (float) - Normalized count of office/business apps installed. - **HII_FIRM_ALL** (float) - Normalized count of manufacturer ecosystem apps installed. - **HUI_GAME_ALL** (float) - Normalized count of mobile game apps uninstalled. - **HUI_SYS_ALL** (float) - Normalized count of system tool apps uninstalled. #### Response Example { "HII_READ_ENCYCLOPEDIA_QA": 0.12, "HII_OB_ALL": 0.45, "HUI_GAME_ALL": 0.05, "HUI_SYS_ALL": 0.10 } ``` -------------------------------- ### Initialize Web SDK Source: https://docs.jiguang.cn/jverification/client/web_api Call this method to initialize the SDK. Ensure you provide your appkey and optionally configure debug mode and domain name. Success and failure callbacks are essential for handling initialization results. ```javascript window.JVerificationInterface.init({ appkey: "极光后台注册的 appkey", debugMode: true, domainName:"https://minio-sdk-res.qa.jiguang.com",//since5.0.0 开发者域名 已极光的 DEMO 域名为例 success: function(data) { //TODO 初始化成功回调 }, fail: function(data) { //TODO 初始化失败回调 } }); ``` -------------------------------- ### Get CUID Source: https://docs.jiguang.cn/public_service/client/Android/sdk_api Retrieves the CUID (Customer Unique ID), which represents the unique ID of the user. Available starting from SDK version 2.0.0. ```APIDOC ## Get CUID ### Description Retrieves the CUID (Customer Unique ID), which represents the unique ID of the user. Available starting from SDK version 2.0.0. ### Method `getCuid()` ### Endpoint `JOperateInterface.getInstance(getApplicationContext()).getCuid()` ### Request Example ```java JOperateInterface.getInstance(getApplicationContext()).getCuid(); ``` ### Response Returns the CUID as a String. ``` -------------------------------- ### 处理应用启动时的本地通知 Source: https://docs.jiguang.cn/jpush/client/iOS/ios_api 在 AppDelegate 的 didFinishLaunchingWithOptions 方法中检查 launchOptions 以获取本地通知内容。 ```Objective-C - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; // 本地通知内容获取:NSDictionary *localNotification = [launchOptions objectForKey: UIApplicationLaunchOptionsLocalNotificationKey] ``` -------------------------------- ### Get Friend List Source: https://docs.jiguang.cn/jmessage/client/ios_sdk/jmessage_ios_appledoc_html/Classes/JMSGFriendManager.html Retrieves the user's friend list from the server asynchronously. It's recommended to call this after the SDK has fully started. ```APIDOC ## GET /friendList ### Description Retrieves the current user's friend list. ### Method GET ### Endpoint /friendList ### Parameters #### Query Parameters - **handler** (JMSGCompletionHandler) - Required - Callback for the result. `resultObject` is an NSArray of `JMSGUser` objects on success, or an `error` object on failure. ### Response #### Success Response (200) - **resultObject** (NSArray) - An array of JMSGUser objects representing the friends. - **error** (NSError) - nil if successful, otherwise contains error information. #### Response Example ```json { "resultObject": [ { "username": "friend1", "nickname": "Friend One", "appKey": "your_app_key" }, { "username": "friend2", "nickname": "Friend Two", "appKey": "your_app_key" } ], "error": null } ``` ``` -------------------------------- ### GET /v3/group/users Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_report Retrieves user statistics for a specified group over a given time period. Supports filtering by time unit, start date, and duration. ```APIDOC ## GET /v3/group/users ### Description Retrieves user statistics for a specified group over a given time period. Supports filtering by time unit, start date, and duration. ### Method GET ### Endpoint https://report.jpush.cn/v3/group/users ### Parameters #### Query Parameters - **time_unit** (string) - Required - Time unit for the statistics. Possible values: HOUR, DAY, MONTH. - **start** (string) - Required - Start time for the statistics. Format depends on `time_unit`: - HOUR: 'YYYY-MM-DD HH' - DAY: 'YYYY-MM-DD' - MONTH: 'YYYY-MM' - **duration** (integer) - Required - Duration of the statistics in the specified `time_unit`. For `time_unit`=DAY, this is the number of days. Limited to 30 days for group applications. For `time_unit`=HOUR, only today's statistics can be output. ### Request Example ```bash curl -v "https://report.jpush.cn/v3/group/users?time_unit=day&start=2020-08-06&duration=2" -u "group-9439ee12e91bd4c895d1b0f5:01bad4e44cecb42b36ea370a" ``` ### Response #### Success Response (200) - **time_unit** (string) - The time unit used in the request. - **start** (string) - The start time used in the request. - **duration** (integer) - The duration used in the request. - **items** (array) - An array of statistics data items. - **time** (string) - The time for the current data item. - **android** (object) - Statistics for Android users. - **new** (integer) - New users. - **online** (integer) - Online users. - **active** (integer) - Active users. - **hmos** (object) - Statistics for HMOS users. - **new** (integer) - New users. - **online** (integer) - Online users. - **active** (integer) - Active users. #### Response Example ```json { "duration": 2, "items": [ { "android": { "active": 7, "new": 5, "online": 11 }, "time": "2020-08-06" }, { "android": { "active": 6, "new": 2, "online": 8 }, "time": "2020-08-07" }, { "hmos": { "active": 7, "new": 5, "online": 11 }, "time": "2020-08-06" } ], "start": "2020-08-06", "time_unit": "day" } ``` ### Error Handling #### Error Codes - **10**: System internal error. - **2003**: Unauthorized to use this interface. - **3001**: HTTP Basic authorization failed. Check Appkey and MasterSecret. - **3004**: `time_unit` and `start` parameter mismatch. - **3005**: Data retrieval limit exceeded (60 days for single app, 30 days for group app). - **3006**: Parameter error (e.g., missing `start_date`). - **3007**: Invalid parameter (e.g., incorrect date format, end time not after start time, future end time). #### Error Response Example (401 Unauthorized) ```json { "error": { "code": 3001, "message": "Basic authentication failed" } } ``` ``` -------------------------------- ### 初始化 JPush SDK Source: https://docs.jiguang.cn/jpush/quickstart/iOS_quick 在 didFinishLaunchingWithOptions 中调用 setupWithOption 初始化 SDK。 ```objective-c 请将以下代码添加到 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ //【初始化sdk】 // notice: 2.1.5 版本的 SDK 新增的注册方法,改成可上报 IDFA,如果没有使用 IDFA 直接传 nil [JPUSHService setupWithOption:launchOptions appKey:appKey channel:channel apsForProduction:isProduction advertisingIdentifier:advertisingId]; } ``` -------------------------------- ### Retrieve User Statistics via API Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_report Example request for fetching user statistics using time units, start date, and duration. Requires Basic Authentication with app credentials. ```bash curl -v "https://report.jpush.cn/v3/users?time_unit=DAY&start=2014-06-10&duration=3" -u "dd1066407b044738b6479275:2b38ce69b1de2a7fa95706ea" > GET /v3/users?time_unit=DAY&start=2014-06-10&duration=3 HTTP/1.1 > Authorization: Basic ZGQxMDY2NDA3YjA0NDczOGI2NDc5Mjc1OjJiMzhjZTY5YjFkZTJhN2ZhOTU3MDZlYQ== ``` -------------------------------- ### Initialize SDK Source: https://docs.jiguang.cn/public_service/client/wxapplet_sdk/sdk_api Initializes the Jiguang SDK using the current context. ```javascript joperate.init(this) ``` -------------------------------- ### Get Friend List - Objective-C Source: https://docs.jiguang.cn/jmessage/client/ios_sdk/jmessage_ios_appledoc_html/Classes/JMSGFriendManager.html Asynchronously retrieves the user's friend list from the server. It's recommended to call this after the SDK has fully started. The handler provides an array of JMSGUser objects on success or an error object on failure. ```Objective-C + (void)getFriendList:(JMSGCompletionHandler)_handler_ ``` -------------------------------- ### Get Chat Room List Source: https://docs.jiguang.cn/jmessage/client/ios_sdk/jmessage_ios_appledoc_html/Classes/JMSGChatRoom.html Use this method to retrieve a paginated list of chat rooms. Specify the appKey (optional, defaults to current app), start index, count per page (max 50), and a completion handler for the results. ```objective-c + (void)getChatRoomListWithAppKey:(NSString *JMSG_NULLABLE)_appKey_ start:(NSInteger)_start_ count:(NSInteger)_count_ completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)_handler_ ``` -------------------------------- ### 初始化 SDK Source: https://docs.jiguang.cn/public_service/client/wxapplet_sdk/sdk_guide 在 app.js 的 onLaunch 生命周期中导入并初始化 SDK,使其在全局可用。 ```javascript var _joperate = require('./joperate-m-2.0.0.js') App({ onLaunch: function () { ··· //在 app onLaunch 调用初始化 _joperate.init(this) } , globalData: { joperate:_joperate } ··· }) ``` -------------------------------- ### 配置小米通道依赖 Source: https://docs.jiguang.cn/jpush/client/Android/android_3rd_guide 在应用模块的 build.gradle 文件中添加小米插件依赖。 ```gradle dependencies { //厂商版本和 JPush SDK 版本保持一致 implementation 'cn.jiguang.sdk.plugin:xiaomi:5.x.x' //说明:JPush SDK v5.2.4 由于特殊原因,引用方式如下 //implementation 'cn.jiguang.sdk.plugin:xiaomi:5.2.4.a' } ``` -------------------------------- ### Get Public Group Info Paginated Source: https://docs.jiguang.cn/jmessage/client/ios_sdk/jmessage_ios_appledoc_html/Classes/JMSGGroup.html Fetches public group information for a given AppKey in a paginated manner. Specify the starting index and the count per page (max 500). Note that the returned objects are JMSGGroupInfo, not JMSGGroup, and are for display purposes only. ```objectivec + (void)getPublicGroupInfoWithAppKey:(NSString *JMSG_NULLABLE)_appkey_ start:(NSInteger)_start_ count:(NSInteger)_count_ completionHandler:(JMSGCompletionHandler)_handler_ ``` -------------------------------- ### GET 回调地址有效性验证 Source: https://docs.jiguang.cn/jums/advanced/callback 在控制台添加回调地址时,极光会向该地址发起 GET 请求进行有效性校验。开发者需在响应中原样返回 echostr 参数值。 ```APIDOC ## GET /callback/verify ### Description 校验回调地址的有效性。极光向配置的 URL 发起 GET 请求,开发者需在响应体中返回请求参数 echostr 的值。 ### Method GET ### Endpoint [Your-Callback-URL]?echostr=[Random-String] ### Parameters #### Query Parameters - **echostr** (string) - Required - 极光发送的随机字符串,需原样返回。 ### Request Example curl -X GET http://callback2pc.com/my/callback/api/sd?echostr=571fd1bfaadc4919a652d56d13925e0f -u 'channelkey:MasterSecret' ### Response #### Success Response (200) - **Body** (string) - 必须原样返回请求中的 echostr 值。 ``` -------------------------------- ### SetUploadFinish Method Source: https://docs.jiguang.cn/jmessage/client/im_android_api_docs/cn/jpush/im/android/api/content/CompoundContent.html Abstract method to set the upload completion status. This method is for internal SDK use. ```java public abstract void setUploadFinish(boolean isUploadFinish) ``` -------------------------------- ### Initialize SDK with Configuration Source: https://docs.jiguang.cn/jverification/client/ios_api Initialize the SDK using JVAuthConfig. Ensure to set the appKey and optionally the advertisingId. The authBlock will receive the initialization result. ```Objective-C // 如需使用 IDFA 功能请添加此代码并在初始化配置类中设置 advertisingId NSString *idfaStr = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; JVAuthConfig *config = [[JVAuthConfig alloc] init]; config.appKey = @"AppKey copied from JiGuang Portal application"; config.advertisingId = idfaStr; config.authBlock = ^(NSDictionary *result) {NSLog(@"初始化结果 result:%@", result); }; [JVERIFICATIONService setupWithConfig:config]; ``` ```Swift let adString = ASIdentifierManager.shared().advertisingIdentifier.uuidString let config = JVAuthConfig() config.appKey = "a0e6ace8d5b3e0247e3f58db" config.authBlock = {(result) -> Void in if let result = result {if let code = result["code"], let content = result["content"] {print("初始化结果 result: code = \(code), content = \(content)")}} } JVERIFICATIONService.setup(with: config) ``` -------------------------------- ### Error Response Example Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_report Example of an error response returned when authentication fails. ```json < HTTP/1.1 401 Unauthorized < Content-Type: application/json < { "error": { "code": 3001, "message": "Basic authentication failed" } } ``` -------------------------------- ### 获取用户列表工具命令 Source: https://docs.jiguang.cn/jums/senderguide/jums-to-alipay 使用极光提供的 pushtool 工具获取用户列表,需替换为实际的 AppID 和 PrivateKey。 ```bash ./pushtool alipay -appid xxx -privatekey xxx ``` -------------------------------- ### API Response Examples Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_image Examples of successful and failed API responses in JSON format. ```json HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Success Response Data { "media_id": "jgmedia-1-6d98e85f-d3a5-412a-bdec-de1b75bd3ad3", // 更新的 media_id ,推送时可将该id作为参数传递给 Push 推送接口,具体见参考 "oppo_image_url": "3653918_3_5f9a5f7cb3c87bf699b332a5", // 适配 OPPO 要求后 OPPO 响应得到的 id "xiaomi_image_url": "http://f8.market.xiaomi.com/download/MiPass/0dfdb5eba1bbb8d1671983fdb2be94074ec/8a350da36d46835768f17f48a6b12b2765cec115.png", // 适配小米要求后小米响应得到的图标地址 "huawei_image_url": "", "honor_image_url": "", "fcm_image_url": "", "jiguang_image_url": "" } ``` ```json HTTP/1.1 400 OK Content-Type: application/json; charset=utf-8 Failed Response Data { "error": { "code": 1002, "message": "Missing authen info." } } ``` -------------------------------- ### SDK Initialization (Version 2.0.7+) Source: https://docs.jiguang.cn/public_service/client/iOS/sdk_api Initializes the SDK. This is the basic initialization method for SDK versions 2.0.7 and above. ```APIDOC ## SDK Initialization (Version 2.0.7+) ### Description Initializes the SDK. This is the basic initialization method for SDK versions 2.0.7 and above. ### Method `+ initializeSDK` ### Endpoint N/A (SDK Method) ### Request Example ```objective-c [JOPERATEService initializeSDK]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### SDK Initialization Source: https://docs.jiguang.cn/jverification/client/web_api Initializes the Jiguang Web SDK with the provided configuration. ```APIDOC ## window.JVerificationInterface.init(Object) ### Description Initializes the SDK. ### Parameters #### Request Body - **appkey** (string) - Required - Jiguang backend assigned appkey - **debugMode** (boolean) - Optional - Whether to enable debug mode, default false - **domainName** (string) - Optional - Developer domain name - **success** (function) - Optional - Callback function on success - **fail** (function) - Optional - Callback function on failure ### Response #### Success Response (200) - **code** (number) - Return code, 0 for success - **message** (string) - Result description ``` -------------------------------- ### API Response Examples Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device Standard HTTP response headers and error body examples. ```HTTP HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 ``` ```HTTP HTTP/1.1 400 BAD REQUEST Content-Type: application/json; charset=utf-8 ``` ```JSON { "error":{"code":7013,"illegal_rids":["010922a358e"]} } ``` -------------------------------- ### Error Response Example Source: https://docs.jiguang.cn/jpush/server/push/rest_api_admin_api_v1 Examples of error responses for app deletion and certificate upload operations. ```json {"error":{"code":1015,"message":"app delete fail"}} ``` ```json {"success":"Synchronized success"} ``` ```json {"error":{"code":1012,"message":"certificate invalid"}} ``` -------------------------------- ### Short Link Query Example with cURL Source: https://docs.jiguang.cn/jmlink/client/rest_api/rest_api_summary Demonstrates how to query short links using the curl command with HTTP Basic Authentication. Ensure your appKey and masterSecret are correctly formatted. ```bash curl --insecure -X GET -v https://api.jpush.cn/v1/links?page_index=1&page_size=20 -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" ``` -------------------------------- ### SDK Initialization Source: https://docs.jiguang.cn/public_service/client/Web/sdk_api Initializes the SDK with the provided configuration. Supports versions 2.0.0 and above. ```APIDOC ## SDK Initialization ### Description Initializes the SDK with the provided configuration. ### Method `init(initConfig)` ### Parameters #### Request Body - **initConfig** (object) - Required - Configuration object for initialization. - **appKey** (string) - Required - The appKey obtained from the Jiguang console. - **debugMode** (boolean) - Optional - Enables or disables debug mode. If true, more log information will be printed. - **channel** (string) - Optional - The channel name. Defaults to 'default-channel'. ### Request Example ```json { "appKey": "9f7248bf870ddec7048e6c0b", "debugMode": true, "channel": "default-channel" } ``` ### Response This method does not return a value directly, but its success is indicated by the absence of errors during initialization. ``` -------------------------------- ### Start Event Timing Source: https://docs.jiguang.cn/public_service/client/Web/sdk_api Records the start time for an event. This method does not send an event immediately. ```javascript let eventID = window.JOperateInterface.timeKeepingEventStart("eventName") ``` -------------------------------- ### Initialize SDK Source: https://docs.jiguang.cn/public_service/client/Android/sdk_api Call this method to initialize the SDK. It is recommended to call it in the Application's onCreate method. Supports versions 2.0.8 and above. ```java JOperateInterface.getInstance(getApplicationContext()).initialize(); ``` -------------------------------- ### Example: Basic HarmonyOS Notification Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push Example JSON payload for a basic HarmonyOS notification with common settings. ```APIDOC ## POST /api/v1/push ### Description Send a basic notification to HarmonyOS devices. ### Method POST ### Endpoint /api/v1/push ### Request Body - **notification** (object) - Required - Contains notification specific settings. - **hmos** (object) - Required - HarmonyOS specific notification settings. - **alert** (string) - Optional - The main alert message. - **title** (string) - Optional - The title of the notification. - **intent** (object) - Optional - Defines the action to take when the notification is tapped. - **url** (string) - Required - The URL or deep link to open. - **badge_add_num** (integer) - Optional - Number to add to the app's badge count. - **extras** (object) - Optional - Custom key-value pairs to include in the notification. - **category** (string) - Optional - Category of the notification (e.g., 'IM'). - **test_message** (boolean) - Optional - Whether this is a test message. - **receipt_id** (string) - Optional - Identifier for message receipt. - **large_icon** (string) - Optional - URL for a large icon to display with the notification. ### Request Example ```json { "notification" : { "hmos" : { "alert":"hmos alert", "title":"hmos titile", "intent": { "url":"scheme://test?key1=val1&key2=val2" }, "badge_add_num":1, "extras": { "age":18 }, "category":"IM", "test_message":false, "receipt_id":"abc1212", "large_icon":"https://www.jiguang.cn/largeIcon.jpg" } } } ``` ``` -------------------------------- ### 配置 mavenCentral 支持 Source: https://docs.jiguang.cn/jpush/client/Android/android_3rd_guide 在 Project 根目录的主 `build.gradle` 文件中配置 `mavenCentral()` 以支持依赖库的下载。新建的 project 默认已配置。 ```gradle buildscript { repositories { ... mavenCentral() ... } } allprojets { repositories { ... mavenCentral() ... } } ``` -------------------------------- ### 初始化 JMLink SDK Source: https://docs.jiguang.cn/jmlink/client/iOS/ios_guide 在 application:didFinishLaunchingWithOptions: 方法中调用 setupWithConfig: 方法来初始化 SDK。需要配置 AppKey 和 advertisingId。 ```objective-c - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //如需使用 IDFA 功能请添加此代码并在初始化配置类中设置 advertisingId NSString *idfaStr = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; JMLinkConfig *config = [[JMLinkConfig alloc] init]; config.appKey = @"your appkey"; config.advertisingId = idfaStr; [JMLinkService setupWithConfig:config]; } ``` -------------------------------- ### Template Push Response Examples Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push_template Examples of successful and failed HTTP responses for template push operations. ```http HTTP/2 200 { "code": 0, "message": "success", "data": { "push_list": [{ // 返回结果是按照请求参数 params 数组下标顺序一一对应 "code": 0, "message_id": "2252000892313098" }, { "code": 0, "message_id": "1098252000313050" }, { "code": 1011, "message_id": "2252000000123130", "message": "cannot find user by this audience or has been inactive for morethan 255 days " }, {, "code": 1003, "message_id": "2252000003001231", "message": "The registration_id aaaa is invalid!" } ] } } ``` ```http HTTP/2 400 { "code": 10004, "message": "Missing parameters" } ``` -------------------------------- ### SDK Initialization with Configuration (Deprecated) Source: https://docs.jiguang.cn/public_service/client/iOS/sdk_api Initializes the SDK using a configuration object. This method is deprecated starting from version 2.0.7. ```APIDOC ## SDK Initialization with Configuration (Deprecated) ### Description Initializes the SDK using a configuration object. This method is deprecated starting from version 2.0.7. ### Method `+ setupWithConfig:(JOPERATEConfig * )config` ### Endpoint N/A (SDK Method) ### Parameters #### Request Body - **config** (JOPERATEConfig) - Required - Configuration object containing appKey and advertisingId. - **appKey** (NSString) - Your application's key. - **advertisingId** (NSString) - The device's advertising identifier. ### Request Example ```objective-c JOPERATEConfig *config = [[JOPERATEConfig alloc] init]; config.appKey = @"your appkey"; config.advertisingId = idfaStr; [JOPERATEService setupWithConfig:config]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### Get Verification Code Button Configuration Source: https://docs.jiguang.cn/jverification/client/ios_api Configure the appearance, text, and layout of the 'Get Verification Code' button. ```APIDOC ## Get Verification Code Button Configuration ### Description Configure the appearance, text, and layout of the 'Get Verification Code' button. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **smsGetCodeBtnCornerRadius** (CGFloat) - Required - Corner radius of the 'Get Verification Code' button. - **smsGetCodeBtnText** (NSString) - Required - Text displayed on the 'Get Verification Code' button. - **smsGetCodeBtnConstraints** (NSArray) - Required - Layout objects for the 'Get Verification Code' button. - **smsGetCodeBtnHorizontalConstraints** (NSArray) - Required - Horizontal screen layout for the 'Get Verification Code' button, takes precedence over smsLogBtnConstraints in landscape mode. - **smsGetCodeBtnTextColor** (UIColor) - Required - Text color of the 'Get Verification Code' button. - **smsGetCodeBtnAttributedString** (UIFont) - Required - Font for the 'Get Verification Code' button text, defaults to system font. - **smsGetCodeBtnImgs** (NSArray) - Required - Array of background images for the 'Get Verification Code' button: [active state image, disabled state image, highlighted state image]. ``` -------------------------------- ### Initialize SDK (iOS) Source: https://docs.jiguang.cn/public_service/client/iOS/sdk_api Initializes the Jiguang SDK. This is the basic initialization method. ```objective-c [JOPERATEService initializeSDK]; ``` -------------------------------- ### Example: HarmonyOS Card Refresh Message Source: https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push Example JSON payload for sending a HarmonyOS card refresh message. ```APIDOC ## POST /api/v1/push ### Description Send a HarmonyOS card refresh message. ### Method POST ### Endpoint /api/v1/push ### Request Body - **notification** (object) - Required - Contains notification specific settings. - **hmos** (object) - Required - HarmonyOS specific notification settings. - **push_type** (integer) - Required - Type of push, set to 1 for card refresh. - **hm_payload** (object) - Required for `push_type=1` - Payload for card refresh. - **formData** (object) - Data for the card form. - **version** (integer) - Version of the form data. - **images** (array of objects) - Images to display on the card. - **keyName** (string) - Name of the image key. - **url** (string) - URL of the image. - **require** (integer) - Indicates if the image is required. - **formId** (integer) - ID of the form. - **moduleName** (string) - Name of the module. - **formName** (string) - Name of the form. - **abilityName** (string) - Name of the ability. ### Request Example ```json { "notification" : { "hmos" : { "push_type":1, "hm_payload": { "formData": { "123": 96, "class": "123" }, "version": 922337203, "images": [ { "keyName": "hello", "url": "https://xxx.png", "require": 1 } ], "formId": 0, "moduleName": "testName", "formName": "testFormName", "abilityName": "testAbilityName" } } } } ``` ```