Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Add a user's first name to create personal push messages: " Hi John, we are...."
  • Add a user's birthday and use it to create a periodic birthday campaign to congratulate users on their birthday
  • Add a user's level in the game and use it to segment the users according to the level they have reached in your game

 

Code Block#pragma mark - Custom Fields /** Set a custom date for a key to Appoxee Servers. @brief Method sets a custom value of NDSate to Appoxee Servers. @code

Objective-C

Code Block
[[Appoxee shared] setDateValue:[NSDate date] forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];
@endcode
@param dateDictionary NSDictionary with an NSDate as a value. Note that only the first key-value pair in the dictionary will be handled.
@param handler Code Block to be executed when method completes with an NSError object and data as arguments.
*/
- (void)setDateValue:(nonnull NSDate *)date forKey:(nonnull NSString *)key withCompletionHandler:(nullable AppoxeeCompletionHandler)handler;
/**
Set a custom number for a key to Appoxee Servers.
@brief Method sets a custom value of NSNumber to Appoxee Servers.
@code
[[Appoxee shared] setNumberValue:@(1.01) forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];
@endcode
@param numericDictionary NSDictionary with an NSNumber as a value. Note that only the first key-value pair in the dictionary will be handled.
@param handler Code Block to be executed when method completes with an NSError object and data as arguments.
*/
- (void)setNumberValue:(nonnull NSNumber *)number forKey:(nonnull NSString *)key withCompletionHandler:(nullable AppoxeeCompletionHandler)handler;
/**
Increment a custom number for a key to Appoxee Servers.
@brief Method increments a custom value of NSNumber to Appoxee Servers. Value is added to an existing key, or else a new entry is created.
@code
[[Appoxee shared] incrementNumericKey:@"key" byNumericValue:@(1.6) withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];

[[Appoxee shared] incrementNumericKeysetStringValue:@"keystring" byNumericValueforKey:@(1.6)"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];
@endcode
@param incrementalNumericDictionary NSDictionary with an NSNumber as a value. Value is will be added to an existing key, else a new key will be created. Note that only the first key-value pair in the dictionary will be handled.
@param handler Code Block to be executed when method completes with an NSError object and data as arguments.
*/
- (void)incrementNumericKey:(nonnull NSString *)key byNumericValue:(nonnull NSNumber *)number withCompletionHandler:(nullable AppoxeeCompletionHandler)handler;
/**
Set a custom string for a key to Appoxee Servers.
@brief Method sets a custom value of NSString to Appoxee Servers.
@code
[[Appoxee shared] setStringValue:@"string" forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

if (!appoxeeError) {

// Operation was successful.
}
}];
@endcode
@param stringDictionary NSDictionary with an NSString as a value. Note that only the first key-value pair in the dictionary will be handled.
@param handler Code Block to be executed when method completes with an NSError object and data as arguments.
*/
- (void)setStringValue:(nonnull NSString *)string forKey:(nonnull NSString *)key withCompletionHandler:(nullable AppoxeeCompletionHandler)handler;
/**
Get a key-value pair stored in cache.
@brief Method gets a key-value pair stored on the device.
@code
[[Appoxee shared] fetchCustomFieldByKey:@"CustomFieldKey" withCompletionHandler:^(NSError *appoxeeError, id data) {

if (!appoxeeError && [data isKindOfClass:[NSDictionary class]]) {

NSDictionary *dictionary = (NSDictionary *)data;
NSString *key = [[dictionary allKeys] firstObject];
id value = dictionary[key]; // can be of the following types: NSString || NSNumber || NSDate
}

// If there wan't an error, and data object is nil, then value doesn't exist on the device.
}];
@endcode
@param key NSString with the key of a previously saved key-value pair.
@param handler Code Block to be executed when method completes with an NSError object and data as arguments.
*/
- (void)fetchCustomFieldByKey:(nullable NSString *)key withCompletionHandler:(nullable AppoxeeCompletionHandler)handler;
/**
Clear cached value of custom fields.
@brief Method clears cached value of custom fields.
@code
[[Appoxee shared] clearCustomFieldsCacheWithCompletionHandler:^(NSError *appoxeeError, id data) {

if (!appoxeeError) {

// custom fields cache was cleared.
}
}];
@endcode
@param handler Code Block to be executed when method completes with an NSError object and data as arguments.
*/
- (void)clearCustomFieldsCacheWithCompletionHandler:(nullable AppoxeeCompletionHandler)handler;
#pragma mark - Device Info
/**
Get information on the current iDevice.
@brief Method gets information on the current iDevice.
@code
// Note that calling this method prior to device registration will provide basic information regarding this device.
// Developers should prefare using deviceInformationwithCompletionHandler:
APXClientDevice *device = [[Appoxee shared] deviceInfo];
@endcode
@param APXClientDevice an instance that describes this device.
*/

[[Appoxee shared] fetchCustomFieldByKey:@"CustomFieldKey" withCompletionHandler:^(NSError *appoxeeError, id data) {

	if (!appoxeeError && [data isKindOfClass:[NSDictionary class]]) {

		NSDictionary *dictionary = (NSDictionary *)data;
		NSString *key = [[dictionary allKeys] firstObject];
		id value = dictionary[key]; // can be of the following types: NSString || NSNumber || NSDate
	}

	// If there wan't an error, and data object is nil, then value doesn't exist on the device.
}];

 

Swift

Code Block
 Appoxee.shared()?.setDateValue(NSDate(), forKey: "key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
     
        // Operation was successful.
    }
})

Appoxee.shared()?.setNumberValue(2, forKey: "key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        // Operation was successful.
    }
})

Appoxee.shared()?.incrementNumericKey("key", byNumericValue: 1, withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        // Operation was successful.
    }
})

Appoxee.shared()?.setStringValue("string", forKey: "key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        // Operation was successful.
    }
})

Appoxee.shared()?.fetchCustomFieldByKey("key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        if let dictionary = data as? NSDictionary {
            
            if let key = data?.allKeys.first {
                
                let value = dictionary.objectForKey(key)
            }
        }
    }
    
    // If there wan't an error, and data object is nil, then value doesn't exist on the device.
})