• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# WantAgent JS API Changelog
2
3## cl.url.1 Trigger API Changes
4trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void ;
5
6This API has been deleted, because some functions have not been implemented. Your application can call the following API:
7
8 trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback<CompleteData>): void
9
10**Change Impact**
11
12Released JS APIs are affected. The application needs to adapt these APIs so that it can be properly compiled in the SDK environment of the new version.
13
14**Key API/Component Changes**
15
16| OpenHarmony 3.2.8.1 API                                 | OpenHarmony 3.2.9.1 SP8 API                             |
17| ------------------------------------------------------------ | ------------------------------------------------------------ |
18| trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void ; | trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback<CompleteData>): void |
19
20**Adaptation Guide**
21
22The following illustrates how to call the alternative **trigger** API in your application.
23
24Example:
25
26```ts
27import WantAgent from '@ohos.app.ability.wantAgent';
28// WantAgent object
29var wantAgent;
30// triggerInfo
31var triggerInfo = {
32        code: 0
33    }
34// WantAgentInfo object
35var wantAgentInfo = {
36    wants: [
37        {
38            deviceId: "deviceId",
39            bundleName: "com.neu.setResultOnAbilityResultTest1",
40            abilityName: "com.example.test.MainAbility",
41            action: "action1",
42            entities: ["entity1"],
43            type: "MIMETYPE",
44            uri: "key={true,true,false}",
45            parameters:
46            {
47                mykey0: 2222,
48                mykey1: [1, 2, 3],
49                mykey2: "[1, 2, 3]",
50                mykey3: "ssssssssssssssssssssssssss",
51                mykey4: [false, true, false],
52                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
53                mykey6: true,
54            }
55        }
56    ],
57    operationType: WantAgent.OperationType.START_ABILITIES,
58    requestCode: 0,
59    wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
60}
61
62// getWantAgent callback
63function getWantAgentCallback(err, data) {
64    if (err == undefined) {
65        wantAgent = data;
66    } else {
67        console.info('getWantAgent failed' + JSON.stringify(wantAgent));
68    }
69    // getUid callback
70    function triggerCallback(err, data) {
71        if(err) {
72            console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
73        } else {
74            console.info('getUid ok!' + JSON.stringify(data));
75        }
76    }
77    try {
78        WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
79    } catch(err) {
80        console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
81    }
82}
83try{
84    WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
85} catch(err){
86    console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
87}
88```
89