gpt4 book ai didi

javascript - 如何在 tizen web 应用程序上获取消息正文?

转载 作者:行者123 更新时间:2023-11-28 01:48:17 37 4
gpt4 key购买 nike

我正在使用我的第一个 tizen 网络应用程序,但无法找出如何正确获取短信正文。尝试这样做:

//Initialize function
var init = function () {
console.log("init() called");

// add eventListener for tizenhwkey
document.addEventListener('tizenhwkey', function(e) {
if(e.keyName == "back")
tizen.application.getCurrentApplication().exit();
});
};


$(document).ready(init);

var MyApp = {};

var smsService;
//Define the success callback.
var messageSentCallback = function(recipients) {
console.log("Message sent successfully to " + recipients.length + " recipients.");
}

// Define the error callback.
function errorCallback(err) {
console.log(err.name + " error: " + err.message);
}

// Define success callback
function successCallback() {
console.log("Messages were updated");
}

//Define success callback
function loadMessageBody(message) {
console.log ("body for message: " + message.subject + "from: " + message.from + "loaded.");
}

function messageArrayCB(messages) {
console.log('Messages: ' + messages.length);
for (var message in messages) {
try{
MyApp.smsService.loadMessageBody(message, loadMessageBody, errorCallback);
}catch(ex) {
console.log("Get exception: " + ex.name + ":" + ex.message);
}
}
}

function serviceListCB(services) {

MyApp.smsService = services[0];
MyApp.smsService.messageStorage.findMessages(
new tizen.AttributeFilter("type", "EXACTLY", "messaging.sms"), messageArrayCB);
}

console.log("run");
tizen.messaging.getMessageServices("messaging.sms", serviceListCB, errorCallback);

但是我在网络模拟器中的控制台上得到了这样的输出:

run main.js:88
init() called main.js:4
Messages: 10 main.js:50
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58
Get exception: NotFoundError:An attempt is made to reference a Node in a context where it does not exist. main.js:58

所以我在调用 loadMessageBody 时遇到问题,因为错误消息来自此代码:

    try{
MyApp.smsService.loadMessageBody(message, loadMessageBody, errorCallback);
}catch(ex) {
console.log("Get exception: " + ex.name + ":" + ex.message);
}

我的代码有什么问题吗?

最佳答案

目前我无法测试它来判断问题所在,但我建议您查看 tizen.org 上的教程: https://developer.tizen.org/dev-guide/2.2.1/org.tizen.web.appprogramming/html/tutorials/communication_tutorial/task_chatter_manage_message.htm

我认为您还可以在 SDK 中找到教程应用程序 (Chatter) 作为示例。

关于javascript - 如何在 tizen web 应用程序上获取消息正文?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20029510/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com