How to show ads in a react native app - facebook

There are some react native components for ads but some of them don't work with current versions of react native. (react-native-admob for example). There is a serious lack of information about showing ads in react native and I can't seem to figure out how most people accomplish this. Does everyone really write their own native UI component to accomplish this? Is react-native-admob really the only way to use admob currently? Am I just completely missing some simple way to do this?

You can try with https://github.com/axemclion/react-native-cordova-plugin and https://github.com/appfeel/admob-google-cordova:
$ npm install react-native-cordova-plugin --save
$ node_modules/.bin/cordova-plugin add cordova-plugin-camera cordova-admob
In android/settings.gradle:
include ':app'
+ include ':cordovaplugin'
+ project(':cordovaplugin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cordova-plugin/framework/android')
In android/app/build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules ...
+ compile project(':cordovaplugin')
}
In android/app/src/main/java/com/appname/MainActivity.java
...
+ import io.cordova.reactnative.CordovaPluginPackage;
...
public class MainActivity extends ReactActivity {
...
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
+ cordovaPluginPackage = new CordovaPluginPackage(this)
);
}
+ private CordovaPluginPackage cordovaPluginPackage;
+ #Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ cordovaPluginPackage.setSavedInstanceState(savedInstanceState);
+ }
+ #Override
+ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ super.onActivityResult(requestCode, resultCode, intent);
+ cordovaPluginPackage.onActivityResult(requestCode, resultCode, intent);
+ }
}
In either index.android.js or any other component:
var Cordova = require('react-native-cordova-plugin');
Cordova.navigator.admob.createBannerView({publisherId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB"});
Cordova.addEventListener(Cordova.navigator.admob.events.onAdLoaded, onEvent);

react-native-admob was a pain to set up. I was beginning to wonder myself if it was broken. But it isn't, you just need to set up a few things. Set up for Android was my biggest issue, but I found this walkthrough guide to help:
https://pradnyachoudhari.wordpress.com/2019/03/22/integrating-google-admob-in-react-native-android-project/
There are also walkthroughs for IOS.
I followed it and it worked for me, although you won't need to add package to MainApplication.java, just import it and you are good.
Hope this helps!

Related

Plugin.LocalNotification doesn't build in Release Mode

I try to add LocalNotification to the application, everything works in Debug mode, but when I change to Release mode, notifications do not work.
Anyone know how to deal with it?
using Plugin.LocalNotification;
namespace TestNotif;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseLocalNotification()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
return builder.Build();
}
}
I got this error CS1061:
Severity Code Description Project File Line Suppression State
Error CS1061 'MauiAppBuilder' does not contain a definition for
'UseLocalNotification' and no accessible extension method
'UseLocalNotification' accepting a first argument of type
'MauiAppBuilder' could be found (are you missing a using directive or
an assembly reference?) TestNotif (net6.0-maccatalyst), TestNotif
(net6.0-windows10.0.19041.0) C:\Users---\source\repos\TestNotif\TestNotif\MauiProgram.cs 14 Active
using Plugin.LocalNotification;
using System;
namespace TestNotif;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
NotificationGet();
}
public async void Button_Clicked(object sender, EventArgs e)
{
var notification6 = new NotificationRequest
{
BadgeNumber = 1,
Description = "Test Description",
Title = "Notification!",
ReturningData = "Dummy Data",
NotificationId = 1327,
Schedule =
{
NotifyTime = DateTime.Now.AddSeconds(5)
}
};
await LocalNotificationCenter.Current.Show(notification6);
}
Fix #1: Only build for Android, to avoid errors when Maui attempts to build release for MacCatalyst and Windows:
Rt-click your Maui project, "Properties".
Application > General, find "iOS Targets > Target the iOS platform: Enable targeting of the iOS platform. UNCHECK.
Similarly find and UNCHECK: Windows Targets > Target ..: Enable targetting of the Windows platform.
Fix #2: Notifications don't work on Android:
Test on an actual device, not on an emulator.
If after both of these, it still doesn't work, then contact author of that plug-in for help.

Unity3D firebase AUTH not working on ANDROID fierbase doesnt connect or something

in editor work fine. i am trying to add my project fierbase and in work. but when i start test at android login window dont react. i am trying to do this
Unity3D firebase AUTH not working on ANDROID
public class FirebaseINIT : MonoBehaviour
{
public static bool firebaseReady;
void Start()
{
CheckIfReady();
}
void Update()
{
if(firebaseReady == true)
{
SceneManager.LoadScene("LoginScene");
}
}
public static void CheckIfReady()
{
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
Firebase.DependencyStatus dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
firebaseReady = true;
Debug.Log("Firebase is ready for use.");
}
else
{
firebaseReady = false;
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
}
}
but not loaded next scene. and i am confused why this happen, i cant do next because dont understand problem. May this will be from android resolve? Because in order to build the project, I must remove the Resolved libraries.
otherwise if I don't remove assets=> Android=> resolve libraries then I will get the following errors
Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
Execution failed for task ':launcher:processReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
the project has an additional plugin for advertising appodeal + admob at least the direction of movement of the study of the issue
and i am integrate this first time i am not sure i am at the right way

Eclipse: How to update View when file open/switch to new file

I am trying to update the view content when I switch or open a new file in the Eclipse project explorer. I tried using "IResourceChangeListener" but it is not triggered (only on changed on the file itself). I also looked looked at https://www.wideskills.com/eclipse-plugin-tutorial (specific on the view part), and Eclipse forums, without success. I thought it would be easy thing... Any Ideas ? small code example will be great !
After hours of searching (and based on #greg-449 comment) I was able to generate a small example that get notified when a new file is opened and is currently visible in the editor:
in the derived ViewPart class:
#Override
public void createPartControl(Composite parent) {
.
.
.
workbench.getPartService().addPartListenr(new IPartListener2() {
public void partOpened(IWorkbenchPartReference partRef) {
String part = partRef.toString();
showMessage("partOpened is " + part);
}
public void partVisible(IWorkbenchPartReference partRef) {
String part = partRef.toString();
showMessage("partVisible is " + part);
}
});
}

Infinite loop in my loading class when debugging/compiling for HTML5 (test_project available)

Recently I added a loading class to my libgdx games (libgdx version 1.3.1). It works fine for the projects android, desktop and IOS.
However, for HTML5 my game never runs and only shows a black screen. Then I found out there is constant(if not infinite) call to .setScreen (new Test(game)) in the code below in my Loading class when I debug it:
#Override
public void render(float delta) {
// Clear the screen
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (game.manager.update() && timeLoading < 0) { // Load some, will return true if done loading
((Game) Gdx.app.getApplicationListener())
.setScreen(new Test(game));
//}
}else{
timeLoading-=Gdx.graphics.getDeltaTime();
}
// Show the loading screen
stage.act();
stage.draw();
}
To make there is nothing wrong with my game I create a project from the scratch using the libgdx gradel tool, compile it using the gwt and the html5 project worked fine.
Then I just added my Loading class in the middle, the desktop works great, but the html5 now behaves as I mentioned above.
Any ideas?
I have uploaded a test project
https://www.dropbox.com/s/ukvik4fcnpzl97a/test_ptoject%202.zip?dl=0
Have the same problem. issue
public class HtmlLauncher extends GwtApplication {
#Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(640, 960);
}
#Override
public ApplicationListener getApplicationListener () {
return new ApplicationListener ();
}
}
htmlLauncher return new ApplicationListener,so
when you ((Game) Gdx.app.getApplicationListener())
your always get new ApplicationListener,
use in your screen a reference to ApplecationListener
public MainMenuScreen(ApplicationListener applicationListener )
{
this.applicationListener=applicationListener ;
}
applicationListener.setScreen();

Eclipse plug-in on project loaded

I have a plug-in and want to detect when projects are added to workspace, to set some project settings from my plug-in code, Any Ideas.
Specially i want to call setHidden in some resources that are derived files, as this settings seems to not be part of the project, i mean whenever a resources is hidden seems to not persist if i import the project in a new workspace.
Ironically, I just wrote something like this yesterday. It is a bit more complicated than you would like. Here is a code snippet for you to play with:
public class ProjectListener implements IResourceChangeListener {
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
List<IProject> projects = getProjects(event.getDelta());
// do something with new projects
}
}
private List<IProject> getProjects(IResourceDelta delta) {
final List<IProject> projects = new ArrayList<IProject>();
try {
delta.accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
if (delta.getKind() == IResourceDelta.ADDED &&
delta.getResource().getType() == IResource.PROJECT) {
IProject project = (IProject) delta.getResource();
if (project.isAccessible()) {
projects.add(project);
}
}
// only continue for the workspace root
return delta.getResource().getType() == IResource.ROOT;
}
});
} catch (CoreException e) {
// handle error
}
return projects;
}
Then, you need to add this ProjectListener to the Workspace, preferably in the start method of your plugin activator:
ResourcesPlugin.getWorkspace().addResourceChangeListener(ProjectListener.LISTENER, IResourceChangeEvent.POST_CHANGE);
And then you want to remove it in the stop method. I literally just wrote this code yesterday. I hope it helps.
You can define a resourcelistener to the workspace, and look for changes in the resource root. See the following article for details: http://www.eclipse.org/articles/Article-Resource-deltas/resource-deltas.html