[英]How to control when Netmera ios sdk will prompt Push notifications permission?
我在我的应用程序中使用Netmera SDK。 在应用启动后立即提示用户允许“推送”通知。 在用户登录我的应用程序后如何控制该行为并询问用户的许可? 添加或删除[Netmera setApiKey:kNetmeraAPIKey];
线没有效果。 即使删除对<Netmera/Netmera.h>
所有依赖关系也无效。 看起来Netmera SDK会以某种方式注入调用registerUserNotificationSettings:
方法...我不知道。 有什么可以解决的办法吗?
当前尚没有简便的方法可以做到这一点。 在下一个主要版本中,将有一个更好的权限管理流程:)
但是,现在您可以执行以下操作:
将类别声明添加到NMPushManager + DisablePushOnLaunchHack.h文件:
#import <Netmera/Netmera.h>
@interface NMPushManager (DisablePushOnLaunchHack)
@end
将类别实现添加到NMPushManager + DisablePushOnLaunchHack.m文件:
#import "NMPushManager+DisablePushOnLaunchHack.h"
@implementation NMPushManager (DisablePushOnLaunchHack)
+ (void)setEnabledUserNotificationTypesInternal:(UIUserNotificationType)type{
// Do nothing.
}
@end
最后,应将#import "NMPushManager+DisablePushOnLaunchHack.h"
添加到AppDelegate类中,以防止Netmera自动注册以推送通知。
之后,您可以随时使用以下代码向用户提示权限警报:
// You can set a different UIUserNotificationType combination
[NMPushManager setEnabledUserNotificationTypes:(UIUserNotificationTypeAlert |
UIUserNotificationTypeSound |
UIUserNotificationTypeBadge)];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.