如何以编程方式在 Watch 上撰写消息? [英] How can I programmatically compose a message on Watch?
本文介绍了如何以编程方式在 Watch 上撰写消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将消息应用程序打开到撰写屏幕,并在消息正文中预加载特定文本?
How can I open the Messages app to the compose screen, with the message body preloaded with specific text?
推荐答案
感谢 @Jatin 找到 openSystemURL(url: NSURL)
函数.
Thanks to @Jatin for finding the openSystemURL(url: NSURL)
function.
代码如下:
let messageBody = "Hello World!"
let urlSafeBody = messageBody.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
WKExtension.sharedExtension().openSystemURL(NSURL(string: "sms:&body=\(urlSafeBody)")!)
这篇关于如何以编程方式在 Watch 上撰写消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文