I would like to show the Short-Look or Long-Look interfaces I created for my Apple Watch App.
我想展示一下我为我的Apple Watch应用程序创建的短期或长期界面。
What already works is the following:
已经奏效的方法如下:
The app does some background job and then notifies the user. This happens with a UILocalNotification.
应用程序做后台工作,然后通知用户。这在UILocalNotification中发生。
When the iPhone is locked and the watch is around my arm, the watch will vibrate and show just a simple notification, but not the Long or Short-Look notification.
当iPhone被锁定,手表环绕在我的手臂上时,手表会震动,只显示一个简单的通知,而不是长或短的通知。
I saw that somebody got it working with push notifications -> Apple Watch: dynamic Long Look not shown, when push opened from Notification Center Currently my app does not support push.
我看到有人用推送通知——> Apple Watch:动态长看不显示,当推送从通知中心打开时,我的应用程序不支持推送。
Does anyone know a way to present Long or Short-Look notifications without a server that does the push stuff?
有没有人知道有一种方法可以在没有服务器的情况下显示长或短的通知?
I send the notification with the following code:
我以下列代码发出通知:
var localNotification = UILocalNotification()
//---the message to display for the alert---
localNotification.alertBody =
"You have entered the region you are monitoring"
//---uses the default sound---
localNotification.soundName = UILocalNotificationDefaultSoundName
//---title for the button to display---
localNotification.alertAction = "Details"
//---display the notification---
UIApplication.sharedApplication().presentLocalNotificationNow(localNotification)
Best regards,
最好的问候,
Simon
西蒙
2 个解决方案
#1
1
You have to set the 'category' property with value matching the one in the watch app storyboard.
你必须设置“category”属性与watch app storyboard中的值匹配。
#2
0
In your NotificationController.swift file (or whatever you may have named your custom WKUserNotificationInterfaceController class), did you uncomment the function "didReceiveLocalNotification" (it's commented out by default)? I don't think the watch will display a Short- or Long-Look notification otherwise.
在你NotificationController。swift文件(或者任何您可能给自定义的WKUserNotificationInterfaceController类命名的东西),您是否取消了函数“didReceiveLocalNotification”的注释(默认情况下是注释掉的)?我不认为手表会显示出一个短的或长的通知。
EDIT: I was mistaken; that function only relates to the dynamic (Long-Look) interface, not the static interface. I'm not sure why the static interface wouldn't appear.
编辑:我错了;该函数只与动态(长时间查看)接口有关,而与静态接口无关。我不确定为什么静态接口不会出现。
#1
1
You have to set the 'category' property with value matching the one in the watch app storyboard.
你必须设置“category”属性与watch app storyboard中的值匹配。
#2
0
In your NotificationController.swift file (or whatever you may have named your custom WKUserNotificationInterfaceController class), did you uncomment the function "didReceiveLocalNotification" (it's commented out by default)? I don't think the watch will display a Short- or Long-Look notification otherwise.
在你NotificationController。swift文件(或者任何您可能给自定义的WKUserNotificationInterfaceController类命名的东西),您是否取消了函数“didReceiveLocalNotification”的注释(默认情况下是注释掉的)?我不认为手表会显示出一个短的或长的通知。
EDIT: I was mistaken; that function only relates to the dynamic (Long-Look) interface, not the static interface. I'm not sure why the static interface wouldn't appear.
编辑:我错了;该函数只与动态(长时间查看)接口有关,而与静态接口无关。我不确定为什么静态接口不会出现。