Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More doc or an example? #1

Closed
lolaswift opened this issue Jun 15, 2018 · 34 comments
Closed

More doc or an example? #1

lolaswift opened this issue Jun 15, 2018 · 34 comments

Comments

@lolaswift
Copy link

lolaswift commented Jun 15, 2018

I am looking for a plugin which displays native Ads.
Is this working with the latest SDK?
Can you add more doc how to use it?
Will you maintain this plugin?

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Hi,

Thank for your attention.
It is facebook ads plugin forked from cordova-plugin-facebookads

It only support Native ads (not banner, interstitial, etc,...) for our project.
It not work with the Lastest SDK. We use SDK version 4.28.1 (maybe update 4.99+ in future)

Use and example same with cordova-plugin-facebookads mention above.
Just replace event name:
Native ads loaded: 'stionic.native.loaded'
Native ads load failed: 'stionic.native.failed'
Native ads clicked: 'stionic.native.clicked'

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

thanks for your quick response. I will give it a try. I tried cordova-plugin-facebookads but it's broken because of some sdk change. Not sure if I can make it through using yours.
Another question, their admob pro has Ad sharing and server control. I don't know obj c. Do you know that if they do the same with this plugin as well?
Thanks again Stionic. regards from Europe

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Yeah, Facebook have updated their SDK on 12/06. It is why this plugin not work if not update.
Also if update SDK 4.99+ will hard to get Icon and Media image url, because Facebook have changed it.

Our plugin limited SDK version 4.28.1 so it working.

For Admob you can try cordova-plugin-admob-free
Your app use this Admob plugin and our Facebook ads plugin, so we can show Ads banner, interstitial, rewards from Google Admob and Native ads from Facebook.

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

@stionic

Yes, mainly because of the server control(all requests will go to their server first), I abandoned their AdMob Pro plugin and I've started using cordova-plugin-admob-free which is awesome. For us, the server control part wasn't acceptable because we have a strict privacy law here in Europe.

And my apology because my second question wasn't clear. I actually meant that if your plugin contained the similar server control code since it's forked from the one made by the same author FloatingHotSpot. I am not sure if they add those server control code to that facebook ads plugin as well just like how they did it to the admob pro plugin. I hope I've managed to explain my concerns well :-). If there is no control code in this plugin, I will start testing and use it in production.

If I can make it work, I definitely will buy you a drink at least. Anyway, appreciated so much already for publishing this plugin. I believe many other people will benifit from your work as well. Just starred your plugin and I was the first one. :-) Yes!

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

@lolaswift

"I actually meant that if your plugin contained the similar server control code since it's forked from the one made by the same author FloatingHotSpot"
=> Ah, Answer is NO. Our plugin forked and removed all compiled binary code, control server. Control code FloatingHotSpot use in cordova-plugin-extension plugin.
Our plugin is Fully Open Sourced, anyone can check in src folder ;)

Regards.

@lolaswift
Copy link
Author

You are awesome man! I am going to test it.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

@stionic
Can you please give me a hand?
The installation of the plugin went OK however, when I build for android:

==============================================================
FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/xx/Documents/git/pj/testapp/platforms/android/build.gradle' line: 266

  • What went wrong:
    A problem occurred evaluating root project 'android'.

Could not get unknown property 'ANDROID_AUDNET_SDK_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
=============================================================

In my build.gradle file:

// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v4:24.1.1+"
compile "com.android.support:support-v4:26.+"
compile "com.android.support:appcompat-v7:26.+"
compile "com.facebook.android:audience-network-sdk:$ANDROID_AUDNET_SDK_VERSION"
compile "com.google.android.gms:play-services-ads:+"
compile "com.android.support:support-v4:$ANDROID_SUPPORT_VERSION"
// SUB-PROJECT DEPENDENCIES END

I tried to change $ANDROID_AUDNET_SDK_VERSION to 4.28.1 but everytime I build, it gets overwritten.

And this line "compile "com.android.support:support-v4:$ANDROID_SUPPORT_VERSION"" shouldn't be added either since it's already added.

Any idea?

@lolaswift
Copy link
Author

And in my project.properties, also added:

target=android-26
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-android-play-services-gradle-release/app-cordova-android-play-services-gradle-release.gradle
cordova.gradle.include.2=cordova-plugin-crosswalk-webview/app-xwalk.gradle
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.android.support:support-v4:26.+
cordova.system.library.4=com.android.support:appcompat-v7:26.+
cordova.gradle.include.3=com-stionic-facebookads-sdk/app-fb-adsdk.gradle
cordova.system.library.5=com.facebook.android:audience-network-sdk:$ANDROID_AUDNET_SDK_VERSION
cordova.system.library.6=com.google.android.gms:play-services-ads:+
cordova.system.library.7=com.android.support:support-v4:$ANDROID_SUPPORT_VERSION

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Can you please give me your cordova version, cordova-android platform version, and config.xml?
It seems your cordova not work with preference default value:

<preference name="ANDROID_SUPPORT_VERSION" default="26.+"/>
and
<preference name="ANDROID_AUDNET_SDK_VERSION" default="4.28.+"/>

There line allow easy custom SDK version and default is 26.+ and 4.28.+
But your cordova not replace it with default value.

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

  1. cordova version:
    $ cordova --version
    7.1.0

  2. cordova-android platform version:

    $ cordova platform version android
    Installed platforms:
    android 6.2.1
    ios 4.3.1
    Available platforms:
    blackberry10 ~3.8.0 (deprecated)
    browser ~5.0.0
    osx ~4.0.1
    ubuntu ~4.3.4 (deprecated)
    webos ~3.7.0
    windows ~5.0.0
    www ^3.12.0

Note: My app is ionic 1.x and I have to force cordova-android to 6.2.1. Otherwise, I got all kinds of build errors.

  1. Config. xml

     <plugin name="com-stionic-facebookads" spec="~1.0.2">
         <variable name="ANDROID_SUPPORT_VERSION" value="26.+" />
    </plugin>
    

I noticed that the $ANDROID_AUDNET_SDK_VERSION is defined on the plugin.xml of the sdk plugin but it doesn't get picked up somehow.

@lolaswift
Copy link
Author

I hardcoded the versions 26.+ and 4.28.+ into the plugin files and it didn't complain anymore but got new error:

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: Cannot merge new index 66438 into a non-jumbo instruction!

@lolaswift
Copy link
Author

Then I did this:
Adding the following lines to build.gradle:

dexOptions {
jumboMode true
}

Then the build completed without further errors.

BUILD SUCCESSFUL

Total time: 20.864 secs

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Hi,

Yes, thank for your information. I will add it into custom gradle of this plugin.
We don't get any error because of we also installed com-stionic-plugin.
It have enabled jumboMode. But it should sperate ;)

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

You're welcome.
What should I do with the variable errors? Was it caused by my old cordova-android version?
Should I leave it hardcoded or is there any other ways to fix it?

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Hi,

I think you config.xml already correct.

<plugin name="com-stionic-facebookads" spec="~1.0.2">
      <variable name="ANDROID_SUPPORT_VERSION" value="26.+" />
</plugin>

Maybe it cached, you can check in /plugins/fetch.json

No idea why it not working, can you please try add plugin: cordova-plugin-admob-free
It have same way for SDK version. After install please check build.gradle if it replace or same problem.

Regards.

@lolaswift
Copy link
Author

Very strange. I restored the plugin.xml settings and removed the plugins from fetch.json and built it again. No problems. Just something weired I guess. I am happy at least it passed the build. Thank you so much!!

Just tried to display ads but nothing showed. Now I am going to dig into the issue. Maybe I will need your help again.

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

For show ads so easy.

Just createNativeAd with your ID, listen 'stionic.native.loaded' event. you will get Ads data. Just bind it to HTML element and setNativeAdClickArea. You also need control removeNativeAd.
We have app here:
https://play.google.com/store/apps/details?id=com.stionic.hala
You can see it work perfect in detail posts ;)

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

The ads was created but the listener didn't work. Did I do anything wrong?:

$scope.$on('$ionicView.loaded', function () {
      $ionicPlatform.ready(function () {
        //fb
       if (FacebookAds) {

      console.log("fb plugin found. will create add")
      console.log(FacebookAds)
      FacebookAds.createNativeAd('xxxxxxxxxxxxx', function (data) {
        console.log("creating ads success");
        console.log(data);
      }, function (error) {
        console.log("creating ads error");
        console.log(error)
      });
    }

    document.addEventListener("stionic.native.loaded", function (data) {
      console.log("any fb data?")
      console.log(data)
      var temp = data;

      if (temp.adType == "native") {

        document.getElementById('adIcon').setAttribute("src", temp.adRes.icon.url);
        document.getElementById('adCover').setAttribute("src", temp.adRes.coverImage.url);
        document.getElementById('adTitle').innerHTML = temp.adRes.title;
        document.getElementById('adBody').innerHTML = temp.adRes.body;
        document.getElementById('adSocialContext').innerHTML = temp.adRes.socialContext;
        document.getElementById('adBtn').innerHTML = temp.adRes.buttonText;
      }

    });


  });
});

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Hi, i think simple because of your AD ID, you can listen stionic.native.failed for check error.

Maybe add 'IMG_16_9_APP_INSTALL#'+your_id
It is testing ADS id, hope it help.

Regards.

@lolaswift
Copy link
Author

Thanks for the guidance. Now I got the test ad working.
I display the Ads(currently using the test Ad) using ionic card. I actually fill the $scope.adData with the adRes data returned.
Now maybe a dumb question. About the clicking.
Can I get a url for ngClick so that when user click the card, it will open the Ad?
Sorry, I am using your "issue" part for asking usage question. I am a noob still. Thank you for your help

@lolaswift
Copy link
Author

Just downloaded your app. Beautiful app. Watched and clicked a few ads as well:-)

@stionic
Copy link
Owner

stionic commented Jun 15, 2018

Hi,

You can't get url then set to ngClick.
You should find x, y, width, height of Card element.
x, y is position in device screen.
Then use FacebookAds.setNativeAdClickArea function.

Always scroll view, open menu (if have), leave page, open other page,... you should find x, y, width, height again then setNativeAdClickArea.
For remove area click you can use setNativeAdClickArea(id, 0, 0, 0, 0) or removeNativeAd(id).

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 15, 2018

@stionic
Android is working. Now status is "Send for review".
iOS is not working. Test Ad working but non-test Ad receives "server error 2000". The first Ad request never went through. Tried a new placement also not working. I've installed FB app and login. According to the official doc:
Error 2000 - Server Error. Possibly due to:
Invalid Placement ID - Each Placement and Type has a Unique ID(tried new placement id, same error)
Unsupported or Outdated version of the SDK - please download the latest version or update your Pod if using Cocoa Pods(might be the sdk version? but android is working)
Improper call/usage of the loadAd method. We suggest placing breakpoints on loadAd and any associated methods/callbacks(android is working, ios test ad is working)
Your application should attempt to make another request after 30 seconds.(I only make one request)
Any suggestion?

update: I contacted facebook support and they said I need to download my app from either Google Play or iTunes, with the version of your app integrated with Audience Network. I am a bit confused now. Shouldn't we test live Ads during development phase before submit them to the app stores?

@stionic
Copy link
Owner

stionic commented Jun 16, 2018

Hi,

You can test by use Facebook test ads.
'IMG_16_9_APP_INSTALL#'+your_id

If it not show testing ads mean is have problems here. Make sure that you installed Cocoa Pods.
screen shot 2018-06-16 at 10 17 38 am

Regards.

@lolaswift
Copy link
Author

My current status:
Test Ads is working on iOS. Only when I try to request live Ads, I will get server error 2000.
Test Ads and Live Ads are both working on Android.

So we are not supposed to test Live Ads correct? Live Ads will work after we release the Apps to google plays and apple app stores? Sorry, I've never used Facebook Ads before. A bit confused.

@stionic
Copy link
Owner

stionic commented Jun 16, 2018

Hi,

Yeah, Live ads will work if testing ads work.
You only can get live Ads when your app IN STORE was accepted by Facebook.
Or your device has Facebook App logined Admin account of app that created placement ID.

@lolaswift
Copy link
Author

lolaswift commented Jun 16, 2018

what does this mean "Or your device has Facebook App logined Admin account of app that created placement ID."

Do you mean on the device which I am testing live Ads, I should login my Facebook App with my Facebook account which was used to created the Placement ID? Then the live Ads will work?

@stionic
Copy link
Owner

stionic commented Jun 16, 2018

Hi,
You can read document here:
https://developers.facebook.com/docs/audience-network/testing#testing-real

  • You can test your app or mobile website on physical devices with production ads by ensuring the person testing is added to your Facebook app in any role.
  • Distribute the app to your testers' devices using your preferred distribution method and make sure your testers are added to your business manager settings page.
  • Each of the people you added needs to have the Facebook app installed on their device and log in to it using the Facebook user ID that you added to the Testers role. This is required because Facebook needs to recognize the user as a person in your business in order to return an ad.
  • The person testing can now launch your app and trigger the placements that you want to test. They should see a production ad.

Regards.

@lolaswift
Copy link
Author

I followed that instructions and enabled Ads debugger.
Android is working!
iOS: server error 2000
I suspect that for new apps using Facebook Ads, the latest SDK is required.
By any chance, you can make a plugin with the latest SDK?

@lolaswift
Copy link
Author

Since you've spent so much time helping me. It doesn't matter the result anymore. I'd like to buy you a drink as I promised. Do you have a paypal account? Can you message me?

@stionic
Copy link
Owner

stionic commented Jun 16, 2018

Hi,

So you have created Ads ID for iOS platform and still not show live ads? Please make sure that Ads ID of Android and iOS is different.

Really thank for your kindness. My PayPal is [email protected].

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 16, 2018

I've done everything according to the book. I tried multiple ios placement id. Everything works perfectly on android but production ads just not showing on my iphone. Pretty frustrating.
You've got a lots of patience for me. I am really thankful for your help. Please check your Paypal. I really like your website and your app. I will generate some ads income for you as well from time to time.

@stionic
Copy link
Owner

stionic commented Jun 16, 2018

Hi,

I am sure that your live ads will work perfect after publish to Apple Store and send to Facebook review because of testing ads work fine.

I don't update SDK because of lastest SDK version Facebook not return Media url. It mean can't show ads image in Ionic if use latest version.
Latest SDK just released 4 days ago and i finding the way for get media url in lastest SDK version.

I also thank for your kindness, but please don't click Ads in our app if you don't care about it.
We need regarding Google Terms, make World better!

I need some times for found the way get Media url in lastest version then i can update it.

Regards.

@lolaswift
Copy link
Author

lolaswift commented Jun 16, 2018

Sure. Then I will finish my implementation and release my apps to the app store to see what will happen. btw, have you received the money on paypal? Just sent using an account ended with .ru. I put a message in the note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants