All Products
Search
Document Center

Mobile Platform as a Service:DataCenter FAQs

Last Updated:Mar 13, 2023

This topic summarizes common iOS-related problems and provides solutions to the problems.

How do I use a DataCenter API to set the storage directory?

Answer: Apps that have integrated mPaaS use their own account systems. If you want to manage data using DataCenter, notify DataCenter at the earliest of switching the user database and then notify other business layers.

[[APDataCenter defaultDataCenter] setCurrentUserId:userId];

When you log off, you do not need to call the setCurrentUserId method. DataCenter will continue to open the database used by the last user.

How do I set my default encryption key?

Answer: DataCenter provides a default encryption method. The key will be automatically generated using appKey passed in by the mPaasInit method. We recommend that apps integrated with mPaaS use their own keys.

Implement the following method in the mPaasAppInterface API to pass the key to DataCenter in the form of NSData.

# pragma mark DataCenter

/**
 * If you implement this method, return the default encryption key (32 bytes) used by DataCenter. This key can be managed by Security Guard, or be encrypted, obfuscated, and then written on the client. 
 * If you do not implement this method, DataCenter will use a result calculated by mPaaS and appKey as the encryption key that is also secure. 
 *
 * @ return The key of 32 bytes is stored in NSData.
 */
- (NSData*)appDataCenterDefaultCryptKey;

We recommend that the app generates its own key of 32 bytes, and converts the key into a Base64 string to be saved in Security Guard. Later, you can obtain the string using a static API of Security Guard and parse the string into NSData.

Is DataCenter thread-safe?

Answer: Yes. All the data storage APIs of DataCenter are thread-safe and can be called in all threads.

How do I resolve the conflict with the Baidu Map SDK?

Description: When your app integrates a certain version of Baidu Map SDK, a crash may occur, as shown in the following figure.

baidu-ap

Answer: Complete the following configurations when you initialize your app. Make sure that the version of mPaaS is 10.1.32 or later.

 #import <MPDataCenter/APDataCenter.h>
// Add the following code to the app initialization method.
     APDataCenter.compatibility = YES;

How does archiveObject store and read variables?

Answer: The following code shows how archiveObject stores and reads variables:

  • Store objects persistently:

    MPCodingData *obj = [MPCodingData new];
    obj.name = @"Amelia";:
    obj.age = 1;
    [APUserPreferences archiveObject:obj forKey:@"archObjKey" business:dataBusiness];

Read variables from DataCenter:

MPCodingData *encodeObj = [APUserPreferences objectForKey:@"archObjKey" business:dataBusiness];