firebase / firebase-cpp-sdk

Firebase C++ SDK
http://firebase.google.com
Apache License 2.0
274 stars 114 forks source link

Admob Rewarded video "setUserId" API #21

Open JoHuang opened 5 years ago

JoHuang commented 5 years ago

I would like to setUserId

https://developers.google.com/android/reference/com/google/android/gms/ads/reward/RewardedVideoAd#setUserId(java.lang.String)

via cpp api because I would like to use SSV (server-side verification).

Is it possible via firebase-cpp-sdk? Thanks

a-maurice commented 5 years ago

Hi @JoHuang

Unfortunately, the C++ SDK does not currently support that feature. If it is a pressing need, I would recommend adding it with the open source build of the SDK.

berinhardt commented 4 years ago

I've made a pull request (#31 ) with this issue

berinhardt commented 4 years ago

an interesting temporary work-around this issue if you don't want to compile the libraries is to use the specific device API directly

FOR ANDROID

 public void setupRewardedUserId(final String user) {
     final Activity mSpawner = spawner;
     this.spawner.runOnUiThread(new Runnable() {
             @Override
           public void run() {
             RewardedVideoAd ad = MobileAds.getRewardedVideoAdInstance(mSpawner);
             ad.setUserId(user);
           }
     });

FOR IOS

void SetRewardedUserId(std::string userId) {
   dispatch_async(dispatch_get_main_queue(), ^{
       GADRewardBasedVideoAd* vid = [GADRewardBasedVideoAd sharedInstance];
       vid.userIdentifier = [NSString stringWithUTF8String:userId.c_str()];
   });
}
berinhardt commented 3 years ago

This workaround will stop working against SDK 20 API, because GADRewardBasedVideoAd was deprecated and the new API does not expose a singleton instance of the RewardAd.

jonsimantov commented 3 years ago

Hi @berinhardt,

I commented on your PR that I believe addresses this issue. Please take a look when you can.

Thanks!