Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test required reason API usage in iOS files. #3327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 15 additions & 39 deletions source/plugin/Assets/Plugins/iOS/GADUInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,47 +140,23 @@ void GADUDisableSDKCrashReporting() {

float GADUDeviceScale() { return UIScreen.mainScreen.scale; }

void GADUSetIntegerPreference(const char *key, NSInteger value) {
CFStringRef cfKey = (__bridge CFStringRef)GADUStringFromUTF8String(key);
CFNumberRef cfValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberNSIntegerType, &value);
CFPreferencesSetAppValue(cfKey, cfValue, kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}

void GADUSetStringPreference(const char *key, const char *value) {
CFStringRef cfKey = (__bridge CFStringRef)GADUStringFromUTF8String(key);
CFStringRef cfValue = (__bridge CFStringRef)GADUStringFromUTF8String(value);
CFPreferencesSetAppValue(cfKey, cfValue, kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}

int GADUGetIntegerPreference(const char *key) {
CFStringRef cfKey = (__bridge CFStringRef)GADUStringFromUTF8String(key);
Boolean keyExists;
CFIndex retrievedValue =
CFPreferencesGetAppIntegerValue(cfKey, kCFPreferencesCurrentApplication, &keyExists);
if (!keyExists) {
NSLog(@"Preference with key %s not found or has an invalid format (not int).", key);
}
return (int)retrievedValue;
void GADUSetUserDefaultsInteger(const char *key, NSInteger value) {
[NSUserDefaults.standardUserDefaults setInteger:value forKey:GADUStringFromUTF8String(key)];
}

const char *GADUGetStringPreference(const char *key) {
CFStringRef cfKey = (__bridge CFStringRef)GADUStringFromUTF8String(key);
CFPropertyListRef retrievedValue =
CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
if (retrievedValue == NULL) {
return NULL;
}
CFTypeID typeID = CFGetTypeID(retrievedValue);
if (typeID != CFStringGetTypeID()) {
NSLog(@"Unable to find a string value for key %s.", key);
CFRelease(retrievedValue);
return NULL;
}
NSString *stringPreference = (__bridge NSString *)retrievedValue;
CFRelease(retrievedValue);
return cStringCopy(stringPreference.UTF8String);
void GADUSetUserDefaultsString(const char *key, const char *value) {
[NSUserDefaults.standardUserDefaults setObject:GADUStringFromUTF8String(value)
forKey:GADUStringFromUTF8String(key)];
}

int GADUGetUserDefaultsInteger(const char *key) {
return (int)[NSUserDefaults.standardUserDefaults integerForKey:GADUStringFromUTF8String(key)];
}

const char *GADUGetUserDefaultsString(const char *key) {
NSString *value = [NSUserDefaults.standardUserDefaults
stringForKey:GADUStringFromUTF8String(key)];
return cStringCopy(value.UTF8String);
}

/// Returns the safe width of the device.
Expand Down