我正在尝试更新 iOS 10 上已发送的通知,这是一项新功能。我正在使用 api 调用通过 firebase 发送推送通知。
如果a上线通知应为“a在线” 如果b也上线通知消息应更新为“a和b在线” 如果c也上线通知消息应更新为“a、b和c在线”等等..
我已经使用了这个问题的答案当新通知到达 iOS 10 中的 UNUserNotificationCenterDelegate 时,如何删除以前发送的通知?。每当我的后端发送通知时,我都会在 willPresentNotification 中编写一个逻辑来获取所需的确切消息并更新现有的通知消息。
但它仅在应用程序处于前台或后台时才有效。如果应用程序终止,则前端中没有任何内容可以执行来更新通知消息。所以每次后端发送通知时
我收到“a 在线”、“b 在线”和“c 在线”所有单独的通知。
那么,如何从后端获得所需的行为?我是否必须将推送的通知的标识符保存在数据库中并使用它们远程更新消息?iOS 是否允许后端服务器从远程设备的通知中心获取通知详细信息?如果我们使用后端的标识符,它会相应地更新消息吗?
谢谢
objective-c push-notification apple-push-notifications ios ios10
乍一看,这可能与堆栈溢出的许多其他问题类似,但我没有找到解决我面临的问题的方法。我正在使用 xcode 8.3.2 和 ios 10.3.2 并配置 FCM 以发送推送通知。我在前台、后台和未运行状态下收到推送通知,因此 Firebase 端或证书没有问题。我也为 UNUserNotificationCenter 和 FIRMessaging 设置了委托。我正在通过从 firebase 控制台发送通知来测试服务。当我按下通知启动应用程序时,方法 userNotificationCenter didReceive 响应方法被调用,但是当应用程序处于前台时 userNotificationCenter willPresent 通知不会在通知到达时被调用。我也尝试过启用和禁用方法 swizzling。没有帮助。
push-notification firebase swift3 firebase-cloud-messaging unusernotificationcenter
我正在尝试使用 开始锻炼课程HKWorkoutSession。它没有启动会话。
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .running
workoutConfiguration.locationType = .outdoor
do {
session = try HKWorkoutSession(healthStore: healthStore!, configuration: workoutConfiguration)
session?.delegate = self
session?.startActivity(with: Date())
print((session?.state)!.rawValue)
} catch let error {
print(error)
}
Run Code Online (Sandbox Code Playgroud)
方法HKWorkoutSessionDelegate
func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState, from fromState: HKWorkoutSessionState, date: Date)
永远不会被叫到。
我正在使用swift 4和Socket.IO-Client-Swift,“〜> 13.1.1”(最新版本)。添加套接字处理程序后,我尝试调用socket.connect(),但出现错误“引擎未打开时尝试连接套接字”。因此,我在计时器内添加了socket.connect()代码,并在5秒钟后调用了该代码,因此到那时引擎已经打开并且不再收到该错误。
但是,即使从未调用过connect client事件处理程序,我现在仍然收到错误“尝试在已连接的套接字上连接”。
我已经阅读了文档以及git上发布的所有问题,但没有解释如何解决此问题或为什么会发生此错误。
您可以在下面找到代码和控制台日志。
let manager = SocketManager(socketURL: URL(string: "https://socket.******.**")!, config: [.log(true),.connectParams(["token":Utils.getToken()]),.reconnects(true)])
socket = manager.socket(forNamespace: "/**********")
console log:
2018-02-01 02:20:00.810496+0530 *******[2476:1630437] LOG SocketIOClient{/**********}: Adding handler for event: connect
2018-02-01 02:20:00.837403+0530 *******[2476:1630437] LOG SocketIOClient{/**********}: Adding handler for event: message
2018-02-01 02:20:00.838168+0530 *******[2476:1630437] LOG SocketManager: Manager is being released
2018-02-01 02:20:05.815458+0530 *******[2476:1630437] LOG SocketIOClient{/**********}: Tried connecting on an already connected socket
Run Code Online (Sandbox Code Playgroud)
从控制台日志中,您可以看到我收到“正在释放Manager”错误消息。有没有办法保留经理对象?这是此问题背后的主要原因吗?