Titanium Appcelerator:如何将焦点设置到应用程序窗口?
当事件发生时将应用程序焦点转移到 Titanium 应用程序的 Titanium 方法是什么?例如,我的应用程序不断在后台运行,我希望在电子邮件到达时打开一个窗口。
What is the Titanium method that shifts application focus to the Titanium app when an event occurs? For example, my application is constantly running in the background, and I want a window to open when email arrives.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您希望在设备上收到电子邮件时打开 Ti 应用程序吗?
据我所知,这不会自动发生(因为我可以看到许多开发人员滥用这一点)。
然而,我的建议是,在电子邮件中添加一个 URI 方案(url 链接或按钮),如下所示:
yourApp://view?id=abc
用户可以点击它,它将打开您的应用程序,并打开您应用程序中的窗口/视图/控制器。为此,您需要将 URI 方案添加到您的应用程序,并处理 url、解析它,以及在您的应用程序中使用它的一些有用的东西...具体方法如下:在应用程序的 tiapp.xml 中,为 iOS 添加以下内容:
在 Android 上,清单节点中的 tiapp.xml 中:
在 Alloy.js 中:
在主 app.js 或 index.js 中:
您还可以在此处了解更多详细信息: http://fokkezb.nl/2013/08/ 26/url-schemes-for-ios-and-android-1/
You would like the Ti App to open when you receive an email on the device?
As far as I know, this won't happen automatically (as I could see many developers abusing this).
However, what I suggest is, add a URI Scheme (a url link or button) in the Email something like:
yourApp://view?id=abc
which the user can click on, and it will open your app, and open the window/view/controller within your App. To do so, you will need to add URI schemes to your App, and handle the url, parse it, and so something useful with it in your App... here's how:In the App's tiapp.xml, add this for iOS:
On Android in tiapp.xml in manifest node:
In Alloy.js:
In your Main app.js or index.js:
You can also learn more in much more details here: http://fokkezb.nl/2013/08/26/url-schemes-for-ios-and-android-1/
您可以使用 javascript 的
setTimeOut()
,一旦您的电子邮件弹出窗口、视图或窗口出现,它将启动另一个活动。you can use
setTimeOut()
of javascript which will start another activity once your email popup or view or window does show up.您的示例代码存在一些问题:
myapp://
)handleurl
事件在 Titanium SDK 5.5.0.GA 及更高版本中提供open
/focus
事件如果您遵循该规则,您应该能够接收和处理有关您的应用程序的 URL,谢谢!
There are some issues with your example code:
myapp://
from the browser or other apps)handleurl
event that is available in Titanium SDK 5.5.0.GA and lateropen
/focus
eventIf you follow that rules, you should be able to receive and handle URL's regarding your app, thanks!