【发布时间】:2020-05-06 13:21:19
【问题描述】:
使用UIBackgroundRefreshStatusAvailable,我的应用程序按预期接收静默推送通知,无论是在后台还是前台。
此功能的名称 -- Background App Refresh -- 向我表明它在禁用时不会影响 Foreground 应用程序的行为。
不幸的是,我的应用在前台中没有收到静默推送通知,后台应用刷新被禁用,即UIBackgroundRefreshStatusDenied。
我没有使用用户可见的推送通知,因此UNUserNotificationCenter 等没有参与。
是否可以在禁用后台应用刷新的情况下接收静默推送通知,即UIBackgroundRefreshStatusDenied?
Objective-C,Xcode 11.3.1,部署目标 iOS 10.3。安装了 iOS 12.4.5 的 iPhone 6。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[application registerForRemoteNotifications];
return YES;
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// not called when app in foreground but bg app refresh turned off
}
这是一个示例userInfo dict,didReceiveRemoteNotification 在启用 bg 应用刷新时收到:
{
aps = {
"content-available" = 1;
};
ck = {
ce = 2;
cid = "iCloud.de.udo-thiel.DiskBench";
ckuserid = "_56bd97c2eb1e52d09756163efaab6b02";
nid = "e70e4a8d-d77b-4315-8b3e-d9de229cf083";
qry = {
dbs = 2;
fo = 2;
rid = "Res-iPad 2-16";
sid = "public-results2";
zid = "_defaultZone";
zoid = "_defaultOwner";
};
};
}
【问题讨论】:
-
能分享一下apns请求的payload吗?
-
@AhmetAYGÜN 我添加了一个示例
userInfo,这就是您要的吗?
标签: ios objective-c