Display CFUserNotificationDisplayAlert on iPhone Lock Screen

后端 未结 2 1326
忘了有多久
忘了有多久 2020-12-09 14:14

I m creating an app that has to display CFUserNotificationDisplayAlert even if iPhone Screen is Locked, currently i am using this code

CFOptionFlags response         


        
相关标签:
2条回答
  • 2020-12-09 14:37

    You need to use the kCFUserNotificationAlertTopMostKey key.

    extern CFStringRef kCFUserNotificationAlertTopMostKey;
    CFStringRef keys[] = {
       kCFUserNotificationAlertTopMostKey,
       kCFUserNotificationAlertHeaderKey,
       kCFUserNotificationAlertMessageKey
    };
    CFStringRef values[] = {
       kCFBooleanTrue,
       CFSTR("Title"),
       CFSTR("Message")
    };
    CFDictionaryRef dict = CFDictionaryCreate(NULL, keys, values,     
                                              sizeof(keys)/sizeof(*keys),
                                              &kCFTypeDictionaryKeyCallBacks,
                                              &kCFTypeDictionaryValueCallBacks);
    SInt32 err = 0;
    CFUserNotificationRef notif = CFUserNotificationCreate(NULL,
              0, kCFUserNotificationPlainAlertLevel, &err, dict);
    CFRelease(dict);
    ...
    

    See http://iphonedevwiki.net/index.php/CFUserNotification for all dialog description keys for iPhone OS ≤ 3.1.

    (Note that while it will show on the lock screen, the phone won't wake up by itself.)

    0 讨论(0)
  • 2020-12-09 14:41

    CFUserNotification is not supported on the iPhone OS. Push Notifications are the iPhone equivalent.

    0 讨论(0)
提交回复
热议问题