我想在我的应用中添加一项功能,即用户可以启用和禁用推送通知声音。这是UI:
我正在使用以下代码启用和禁用声音:
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
UIUserNotificationType allNotificationTypes;
UIUserNotificationSettings *settings;
//
if(sound==0 || sound==1)
{
allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
}
else if(sound==2)
{
allNotificationTypes =
(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
}
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
[FIRApp configure];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
name:kFIRInstanceIDTokenRefreshNotification object:nil];
我正在使用firebase进行推送通知。