检查用户是否在iOS中以codenameone接受了推送通知权限

时间:2017-07-06 16:52:24

标签: codenameone

我如何检查用户是否以codenameone或原生语中的ios拒绝或接受推送通知权限消息?

2 个答案:

答案 0 :(得分:0)

Android和iOS都有API来检测是否启用了推送功能: Push Notification ON or OFF Checking in iOS

Android 4.1: How to check notifications are disabled for the application?

由于这些是最近添加的,我们没有得到足够的需求,我们此时不支持它们。您可以使用本机界面调用它们,也可以使用集成提交拉取请求。通常情况下,当推送工作时会有一个推送注册的回调,如果没有错误,则会收到错误或没有错误。

答案 1 :(得分:0)

我找到了一个实现IOS 10原生功能的解决方案

这种方法在Objective-c和codenameone代码

中完美运行
//------------------------------------------------------------------------------
//This method is use to check if the user enable or disable push notification
//------------------------------------------------------------------------------
-(BOOL)isPushNotificationIsEnable{

    if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {
        NSLog(@"isPushNotificationIsEnable()->YES");
        return YES;
    } else {
        NSLog(@"isPushNotificationIsEnable()->NO");
        return NO;
    }
}
//------------------------------------------------------------------------------
//This method is use to launch the Notification screen of your app
//------------------------------------------------------------------------------
Display.getInstance().execute("App-Prefs:root=NOTIFICATIONS_ID&path=your package name app", new ActionListener() {
     String methodName = "startLocationSetting";
      @Override
      public void actionPerformed(ActionEvent evt) {

            boolean status = Utils.isPushNotificationEnable();

      }

});
//------------------------------------------------------------------------------
相关问题