static InitConstants()
        {
#if __MACCATALYST__
            // avoid TypeLoadException if used before macOS 11.x
            if (!UIKit.UIDevice.CurrentDevice.CheckSystemVersion(14, 0))
            {
                return;
            }
#endif
            // ensure we can init. This is needed before iOS6 (as per doc).
            IntPtr p = ABAddressBook.ABAddressBookCreate();

            ABGroupProperty.Init();
            ABLabel.Init();
            ABPersonAddressKey.Init();
            ABPersonDateLabel.Init();
            ABPersonInstantMessageKey.Init();
            ABPersonInstantMessageService.Init();
            ABPersonKindId.Init();
            ABPersonPhoneLabel.Init();
            ABPersonPropertyId.Init();
            ABPersonRelatedNamesLabel.Init();
            ABPersonUrlLabel.Init();
            ABSourcePropertyId.Init();

            // From iOS 6.0+ this might return NULL, e.g. if the application is not authorized to access the
            // address book, and we would crash if we tried to release a null pointer
            if (p != IntPtr.Zero)
            {
                CFObject.CFRelease(p);
            }
        }
Esempio n. 2
0
        static InitConstants()
        {
            // ensure we can init. This is needed before iOS6 (as per doc).
            IntPtr p = ABAddressBook.ABAddressBookCreate();

            ABGroupProperty.Init();
            ABLabel.Init();
            ABPersonAddressKey.Init();
            ABPersonDateLabel.Init();
            ABPersonInstantMessageKey.Init();
            ABPersonInstantMessageService.Init();
            ABPersonKindId.Init();
            ABPersonPhoneLabel.Init();
            ABPersonPropertyId.Init();
            ABPersonRelatedNamesLabel.Init();
            ABPersonUrlLabel.Init();
            ABSourcePropertyId.Init();

            // From iOS 6.0+ this might return NULL, e.g. if the application is not authorized to access the
            // address book, and we would crash if we tried to release a null pointer
            if (p != IntPtr.Zero)
            {
                CFObject.CFRelease(p);
            }
        }