gpt4 book ai didi

ios - iOS 10[ objective-c ]如何实现推送通知?

转载 作者:技术小花猫 更新时间:2023-10-29 10:29:38 27 4
gpt4 key购买 nike

任何人都可以帮助我实现 iOS 10 的推送通知,因为我已经实现了以下代码但仍然遇到问题:

#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0"))
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
}
else {
// Code for old versions
}

我收到错误提示

Unknown receiver UIUserNotificationCenter

提前致谢!

最佳答案

抱歉各位,我得到答案了。我只需要导入 UserNotifications 框架。

#import <UserNotifications/UserNotifications.h>

关于ios - iOS 10[ objective-c ]如何实现推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39850603/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com