【问题标题】:read a new SMS and afterwards change the status to 'read'. Windows Universal app阅读一条新短信,然后将状态更改为“已阅读”。 Windows 通用应用程序
【发布时间】:2016-04-25 14:33:22
【问题描述】:

我可以使用此代码阅读新短信

 Windows.ApplicationModel.Chat.ChatMessageStore store = await Windows.ApplicationModel.Chat.ChatMessageManager.RequestStoreAsync();
        var msgList = store.GetMessageReader();

        IReadOnlyList<Windows.ApplicationModel.Chat.ChatMessage> a = await msgList.ReadBatchAsync();

        foreach (var item in a)
        {
            if (item.IsSeen)
            {

               Don't do anything.. SMS is Readed
            }
            else
            {

             item.IsSeen=True (This not work because don't save this               status)    }

我尝试使用 Mark IsSeen,但它不起作用......有什么想法吗?

【问题讨论】:

  • 我找到了这个说明:markasreadasync 和 markasseenasync 但我不知道如何使用...

标签: windows-phone-8.1 sms win-universal-app


【解决方案1】:

MarkAsSeenAsync 如 MSDN 上所写,将所有传输消息标记为可见。 所以如果你使用

store.MarkAsSeenAsync() 

您将标记所有消息

但是你可以使用第二个覆盖

store.MarkAsSeenAsync(IIterable(String))

作为 IIterable(String) 你可以使用集合

List<string>

带有消息ID。 您的代码将如下所示:

 Windows.ApplicationModel.Chat.ChatMessageStore store = await Windows.ApplicationModel.Chat.ChatMessageManager.RequestStoreAsync();
 var msgList = store.GetMessageReader();
 IReadOnlyList<Windows.ApplicationModel.Chat.ChatMessage> a = await msgList.ReadBatchAsync();

 List<string> l = new List<string>();

 foreach (Windows.ApplicationModel.Chat.ChatMessage item in a)
 {
     if (!item.IsSeen) l.Add(item.Id);
 }

 await store.MarkAsSeenAsync(l);

【讨论】:

  • 嘿,兄弟,你是最好的.. 你给了我这个主意.. 只需要这行:await store1.MarkMessageReadAsync(item1.Id);非常感谢!.. 我不能离开你,因为和一个新手,但真的很感谢!
  • 谢谢你,@abraham。即使你是新来的,我想你也可以标记为答案。
  • 嗨,哥们,不仅有 15 分,我还有 14 XD 真的很难在这里获得一些分数 jejeje.. 如果你投票支持我的帖子,我会转发你的观点
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-19
  • 1970-01-01
  • 1970-01-01
  • 2010-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多