Google Consent SDK: How to Save 'Status' Array in UserDefaults?

96 views Asked by At

The variable "status" is not used in this code. Therefore I cannot check the user's consent choice.

I have to store 'status array' in defaults. Once current status is available in array it will not show that Consent form. If not then we will show form and add that status in defaults status array.

Now I cannot check user's consent choice, and the form will load every time on app load.

This would probably solve the problem, but I do not know how to do that in code. Any suggestions?

status error

 // Load Form
[form loadWithCompletionHandler:^(NSError *_Nullable error) {
    NSLog(@"Load complete. Error: %@", error);
    if (error) {
        // Handle error.
    } else {
        // Load successful.


        [form presentFromViewController:self
                      dismissCompletion:^(NSError *_Nullable error, BOOL userPrefersAdFree) {
                          if (error) {
                              // Handle error.
                          } else if (userPrefersAdFree) {
                              // The user prefers to use a paid version of the app.



                          } else {

                              // Check the user's consent choice.
                              PACConsentStatus status =
                              PACConsentInformation.sharedInstance.consentStatus;


                              // store status array in defaults
                              // once current status is available in array we will not show that form
                             // if not then we will show form and add that status in defaults status array





                              //Storing publisher managed consent
                              PACConsentInformation.sharedInstance.consentStatus = PACConsentStatusPersonalized;



                          }
                      }];
1

There are 1 answers

0
Martin Zeitler On

I have little clue of iOS, but I'd guess you just have to write the assignment into a single line:

PACConsentStatus status = PACConsentInformation.sharedInstance.consentStatus;