【问题标题】:How to control when Netmera ios sdk will prompt Push notifications permission?如何控制 Netmera ios sdk 何时提示推送通知权限?
【发布时间】:2016-01-22 20:39:23
【问题描述】:

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

【问题讨论】:

    标签: ios sdk push-notification apple-push-notifications netmera


    【解决方案1】:

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

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

    将类别声明添加到 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)];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-05
      • 2020-04-07
      • 1970-01-01
      • 2018-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多