How to Test User Consent Status (GoogleMobileAds UMP SDK) - objective-c

I'm in the process of integrating the GoogleMobileAds & User Messenger Platform SDK for iOS.
I understand it offers a way for users to consent or not consent inside the EEA.
Firstly you test to see if consent is required:
UMPFormStatus formStatus = UMPConsentInformation.sharedInstance
.formStatus;
if (formStatus == UMPFormStatusAvailable) {
[self loadForm];
}
...
The Admob guide says you can serve non-personalised ads as follows:
GADRequest *request = [GADRequest request];
GADExtras *extras = [[GADExtras alloc] init];
extras.additionalParameters = #{#"npa": #"1"}; //this being the key line
[request registerAdNetworkExtras:extras];
If the user consents, ads can be loaded fine, as GoogleMobileAds default is to serve personalised ads...
However, if a user does choose not to consent, how do we programmatically test the consent status before loading Ads? Or does the GoogleMobileAds monitor this inside Admob and only serve non-personalised ads based on the users input?
I haven't found an answer to this on Stack or Github etc.
Thank you for your time.
Edit:
I have since discovered that if a user doesn't consent, no ads are shown... But a test to check consent would still be helpful, as you could manually load non-personalised ads (npa)... But I can't find how to test the consent, so the question above, still stands. Thank you.

Related

How do I Login inside app to use GPPNativeShareBuilder of Google API in Objective C?

I am using Google Plus API for login purpose.
My app rejects once due to GPPSignIn (Not Google login within app), then I used GTMOAuth2Authentication for login with Google. This allow me to login inside my app.
This goes well.
I am worrying about share on Google, for same issue (rejection), I implemented GPPNativeShareBuilder, which allows me to share within app, but this goes out of app for login, when tried with same GTMOAuth2Authentication this gives me error message:-
[GPPNativeShareBuilderImpl open] User must be signed in to use the native share box.
I used this also
GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
[plusService setAuthorizer:self.auth]; // authentication object!!!
This produces same warning error, not presents share dialog.
Help me, Thanks in advance.

Connect Facebook Social Plugin with FB iOS SDK

In one of our app, our user already logged in using the iOS FB SDK, and in one page is am displaying the comment box social plugin to render comments, but seems it can't use the existing logged session.
Are there any steps required so user don't need to double login?
Comments box social plugin is not designed for iOS. But we can make it work by restricting the user to sign into FB only using WebView popup. To achieve this, set NO for both authorizeWithFBAppAuth and safariAuth in - (void)authorize:(NSArray *)permissions; method of Facebook.m
- (void)authorize:(NSArray *)permissions {
self.permissions = permissions;
[self authorizeWithFBAppAuth:NO safariAuth:NO];
}
This will store all the facebook credentials in sharedHTTPCookieStorage. Now when you load your comments box social plugin using webview, it will recognize the existing session.

Facebook invitation request is not delivered

I am showing a dialog in an iOS app to allow users to select some friends to whom send an invitation to the app.
The dialog is displayed, you can select some friends and press send.
Dialog delegate method callback is called successfuly.
So far so good, but the friend is not receiving any invitation,
is that because the app is still in development?
This is the code I am using to show the dialog, is there any missing parameter?
(access token is fine because the app works).
// Show the UI Dialog
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kFacebookAppID,#"access_token", #"Invitation message", #"message",nil];
[facebook dialog:#"apprequests"andParams:params andDelegate:self];
Requests are only delivered if the user can reasonably be expected to accept them; if your app is only an iOS app (i.e no canvas implementation / apps.facebook.com URL) then they'll only be displayed in the Facebook app for iOS.
If this isn't happening it may be because your SSO settings for the app aren't correct, so Facebook's app doesn't know how to bring users to your app when they accept the request, check those first - making sure the URL handler is set up correctly in your app, etc.
It may also be because the app is in sandbox mode, but i'm not sure about that one.

FBConnect login, share with a webview?

I am using FBConnect in my iOS project to authorize the user (SSO).
Once logged in, I sometimes need to open a Webview in order to show the user specific dialogs such as the app request dialog (invite to app) and even to open a friend's profile page in a webview for my app user to browse.
The problem is that the Webview doesn't recognize the logged in user and asks him to login again, this is not very friendly.
Any ideas how to share the logged in auth key/cookie/something with the webview?
You are likely running into this situation. It's really frustrating.
Facebook iOS SDK not storing cookies for access
You can, if you want, force the iOS library to use your app for login, and authorize through a UIWebview local to your app. You are thus logged in, and have cookies to use. You'll have to add a method to the existing Facebook object. Normally, you call:
- (void) authorize:(NSArray *)permissions
delegate:(id<FBSessionDelegate>)delegate
to authorize, which in turns calls the private method:
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth
with both parameters set to YES.
You want to add a public method that calls the same private function but with both parameters set to NO. I added this method to Facebook.m and declared it in Facebook.h so I could call it however I like:
- (void)authorize:(NSArray *)permissions
tryFBApp:(BOOL) tryFBApp
trySafariAuth:(BOOL) trySafariAuth
delegate:(id<FBSessionDelegate>)delegate {
[_permissions release];
_permissions = [permissions retain];
_sessionDelegate = delegate;
[self authorizeWithFBAppAuth:tryFBApp safariAuth:trySafariAuth];
}
I call that with the two BOOL parameters set to NO, and the library pops ups a local UIWebView that leaves me with cookies that work for the app.
FBConnect returns you a token so that you have access to the FB API not the FB website. Unfortunately this doesn't login them in through a UIWebView and set the proper FB cookies.
Another strategy would be to change in the FBConnect source code to redirect to your own UIWebView instead of the standard FB pop-out to the FB-APP process and have them login only once. You would however have to persist the cookie state of the UIWebView.
I suggest that you also take a look at http://www.getsocialize.com which can help you manage social network integration.
good luck!

need help to get Facebook profile picture. Also is GRAPH Api online test site down?

I followed the instructions from github.com/facebook/facebook-ios-sdk
and can get Facebook login dialog and get connected. It's for ipad application to get FB info. user name, friend list can be fetched correctly.
I tried to get the profile picture
[_facebook requestWithGraphPath:#"me/picture" andDelegate:self];
and received response:There was a problem communicating with server...
but similar calls like
[_facebook requestWithGraphPath:#"me/posts" andDelegate:self];
[_facebook requestWithGraphPath:#"me/friends" andDelegate:self];
work just fine.
also tried the facebook graph API online test site:
https://developers.facebook.com/tools/explorer/
to use it, first get access token, then tried to get posts, friends, and they are fine.
but when to get picture will take forever, and never return anything.
I did log into my facebook account in a web browser and the profile picture appears just fine.
The Graph API for the user endpoint is described here:
http://developers.facebook.com/docs/reference/api/user/
About the picture connection, it says:
HTTP 302 redirect to URL of the user's profile picture (use ?type=square | small | normal | large to request a different photo).
So what you get is not the typical JSON response, but the picture itself (via the HTTP redirect). You can try that by entering the graph API call into your browser location bar. For example, to see the profile pic of Mark Zuckerberg, try:
http://graph.facebook.com/markzuckerberg/picture