我想对我正在编写的应用程序中的另一个应用程序的远程推送通知采取行动。这可能吗?
我一直在(成功地)使用 Google Firebase Messaging 系统。我可以向我的 iPhone 发送消息并订阅/取消订阅群组/主题,现在我想在推送通知到达手机时对其进行管理和处理。
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
print("1 Message ID: \(messageID)")
}
// Print full message.
print(userInfo)
// Change this to your preferred presentation option
completionHandler([])
}
Run Code Online (Sandbox Code Playgroud)
这是来自谷歌的默认代码,当推送通知到达应用程序看到并打印时,它工作正常:
1 Message ID: 0:1007%4xxxxxxxxxa
[AnyHashable("gcm.message_id"): 0:1007%4xxxxxa, AnyHashable("aps"): {
alert = {
body = "Breaking News: "; …Run Code Online (Sandbox Code Playgroud) 我使用自己的服务器,使用FCM向ios设备推送通知,推送通知成功,我还使用Realm数据库系统帮我存储fcm推送通知,但是只有以下两种情况存储才会成功。情况1:当应用程序运行时。
情况2:当您点击推送横幅通知时,应用程序被杀死或在后台运行。
但这不是我的主要意图。我知道当应用程序被终止时,我无法处理推送通知,因此我希望能够在用户打开应用程序时存储推送通知。
抱歉,我的英语不好。如果有不清楚的地方,请告诉我。
境界级
class Order: Object {
@objc dynamic var id = UUID().uuidString
@objc dynamic var name = ""
@objc dynamic var amount = ""
@objc dynamic var createDate = Date()
override static func primaryKey() -> String? {
return "id"
}
let realm = try! Realm()
let order: Order = Order()
Run Code Online (Sandbox Code Playgroud)
AppDelegate.swift(当应用程序运行时存储 fcm 消息)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo //
print("userInfo: \(userInfo)")
guard
let aps …Run Code Online (Sandbox Code Playgroud) 我的应用程序没有任何 VoIP 功能,例如音频/视频通话。如果我使用 VoIP 通知,苹果会拒绝我的申请吗?使用这个有什么限制吗?
我需要 VoIP 通知,因为即使用户终止应用程序,也能保证应用程序在后台启动。
我需要一些帮助。
我完全不知道为什么我的通知不起作用。
我的 AppDelegate 看起来像这样:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
print("token: \(token)")
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("failed to register for remote notifications with with error: \(error)")
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { …Run Code Online (Sandbox Code Playgroud) 我尝试过 Firebase 推送通知,但它不起作用。远程消息显示在带有负载的控制台上,但未在模拟器上显示通知。我使用 Xcode 11.5 和 iOS 13。
objective-c apple-push-notifications ios firebase firebase-cloud-messaging
我想知道是否可以通过APNS发送推送通知,如果应用程序未启动则不显示通知?(在这种情况下,收到的消息将被丢弃)
谢谢
我正在为Iphone开发推送通知的应用程序.在我的应用程序中,我有两个列表视图(UITableView)第一个用于类别列表,第二个是内容列表.用户单击所需的类别,然后将显示与该类别相关的内容,然后用户将选择内容,并且内容将显示在详细视图中(通常是UIWebView).
推送通知已成功进入我的应用程序.我的要求是: - 点击Push alert的VIEW按钮后,应用程序将直接显示特定的详细视图(UIWebView)[省略类别和内容列表].我有类别和内容的唯一ID.那么请您指导我如何将特定内容与推送通知相关联并直接显示该内容.
感谢致敬.
我的Apple Notification有时会收到一些无法访问设备.当Apple Notification失败时,请帮助我并告诉不同的场景.
任何帮助将非常感激.