1

我在我的应用程序中使用 Netmera SDK。它会在应用程序启动后立即提示用户对推送通知的许可。在用户登录我的应用程序后,如何控制该行为并征得用户的许可?添加或删除[Netmera setApiKey:kNetmeraAPIKey];行无效。即使删除所有依赖项<Netmera/Netmera.h>也没有效果。看起来像 Netmera SDKregisterUserNotificationSettings:以某种方式注入调用方法......我不知道。有什么解决方法可以解决这个问题吗?

4

1 回答 1

2

目前没有一种简单的方法可以做到这一点。在下一个主要版本中,将会有一个更好的权限管理流程 :)

但是,现在您可以执行以下操作:

在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)];
于 2016-01-22T12:39:23.463 回答