The banner not showing with my id from adMob Ionic 3 - ionic-framework

when i'll try run my application in my device with this code:
ionic cordova build android
It is generated an APK and I installed in my device. When i build with this code, the Ads works:
showAd() {
const bannerConfig: AdMobFreeBannerConfig = {
isTesting: true,
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow to false, then we will need to call the show method here
})
.catch(e => console.log(e));
}
When I build with this other code, the Ads not show:
showAd() {
const bannerConfig: AdMobFreeBannerConfig = {
id: 'MY-ID-FROM-ADMOB',
isTesting: false,
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
// if we set autoShow to false, then we will need to call the show method here
})
.catch(e => console.log(e));
}
Someone help me, please...
Sorry if I wrote wrong something, my english is not very well...

thanks suzan for share but it is not the solution. After 3 days I finally succeed publishing my app with ads.
I searched many solution, and in this post: ionic-3-admob-free-not-displaying-ads-when-testing-is-false Says that i needed to added my address on the payment page.
In the cordova-plugin-admob-free site, i read that i needed added this code in my config.xml:
<plugin name="cordova-admob-sdk" spec="~0.13.1">
<variable name="PLAY_SERVICES_VERSION" value="11.6.0" />
</plugin>
I tested with this adID: ca-app-pub-3940256099942544/6300978111, this adId is found in google test Ads site, and worked!
When I was test with my adId showed a black rectangle istead of the Ads, i ignore it, because in google Admob FAQ says: When new apps are registered with AdMob,may taken a time for working. (summarizing)
When I published in Play store, the Ads are showing!!
Thanks for all =)

Well, it takes a while to display ads using the new adMob ad-ID.
And you should remove the isTesting from the admob config.
showAd() {
const bannerConfig: AdMobFreeBannerConfig = {
id: 'MY-ID-FROM-ADMOB',
autoShow: true
};
this.admobFree.banner.config(bannerConfig);
this.admobFree.banner.prepare()
.then(() => {
// banner Ad is ready
})
.catch(e => console.log(e));
}
It may take certain days or a day

Related

How to use Pushwoosh in Ionic 5 project with capacitor

Hi everyone I am migrating an app from ionic 1 to ionic 5 and I need to integrate the pushwoosh notification service, my project was started not using cordova, instead I use capacitor and I can't find information about how to integrate this service to an ionic 5 application.
Please, we already know that you can use cordova but when using the cordova plugin add pushwoosh-cordova-plugin#8.0.0 it gives you the following message:
Current working directory is not a Cordova-based project.
because as I said before it is a capacitor project not a cordovan project, Btw I already use ionic integrations enable cordova
So... if anyone can help us, It would be very helpful.
OK guys after many hours trying to integrate Pushwoosh into an ionic 5 application for me it was impossible,
If you set everything up correctly, the following will happen:
Your app will connect to Pushwoosh correctly
Your app will correctly register your device in pushwoosh
But your app will not listen to the listeners offered by the official Pushwoosh documentation
document.addEventListener('push-receive',
function (event) {
var message = (<any>event).notification.message;
var userData = (<any>event).notification.userdata;
alert("Push message received: " + message);
console.info(JSON.stringify((<any>event).notification));
//dump custom data to the console if it exists
if (typeof (userData) != "undefined") {
console.warn('user data: ' + JSON.stringify(userData));
}
}
);
This does not work in an ionic 5 app 👆🏽
This does work:
import { Component, OnInit } from '#angular/core';
import {
Plugins,
PushNotification,
PushNotificationToken,
PushNotificationActionPerformed,
} from '#capacitor/core';
const { PushNotifications } = Plugins;
#Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
ngOnInit() {
console.log('Initializing HomePage');
// Request permission to use push notifications
// iOS will prompt user and return if they granted permission or not
// Android will just grant without prompting
PushNotifications.requestPermission().then(result => {
if (result.granted) {
// Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register();
} else {
// Show some error
}
});
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
alert('Push registration success, token: ' + token.value);
},
);
PushNotifications.addListener('registrationError', (error: any) => {
alert('Error on registration: ' + JSON.stringify(error));
});
PushNotifications.addListener(
'pushNotificationReceived',
(notification: PushNotification) => {
alert('Push received: ' + JSON.stringify(notification));
},
);
PushNotifications.addListener(
'pushNotificationActionPerformed',
(notification: PushNotificationActionPerformed) => {
alert('Push action performed: ' + JSON.stringify(notification));
},
);
}
}
I tried to combine Pushwoosh with the capacitor but the tokens of the devices that are generated are different so I still didn't get my notifications.
At the end of the day and after many hours and days of work I have no other option than to use firebase and now everything is going much better.

Ionic 4 + Google Analytics plugin: trackView does not work

I'm trying to implement Google Analytics tracking in my Ionic 4 app (with the native plugin).
I have generated the tracking code and in my app.component.ts I have this:
this.ga.startTrackerWithId(environment.ga)
.then(() => {
console.log('started track!');
this.ga.trackView('App component')
.then(() => { console.log('track view')})
.catch(e => console.log(e));
this.ga.trackEvent('root', 'open')
.then(() => { console.log('track event')})
.catch(e => console.log(e));
})
.catch(e => alert('Error starting GoogleAnalytics == '+ e));
the startTrackerWithId method runs ok, I can see in the Analytics real-time console a new user is active. The trackEvent works fine, too; the event 'root' is shown in the console.
But the trackView does not work. No view is tracked in the console, and when I open the Chrome' s console, no request is being made to the Analytics server. But the 'console.log('track view')' is being called, in other words, no error is being thrown.
Any clue?

Can't receive push notifications using Ionic Cloud on iOS

I'm using ionic's cloud push notification service for both android and iOS, along with phonegap-plugin-push. Since i'm using my own server-side authentcation and not ionic's, I have it configured so that a user's authentication token is registered depending on whether or not they're logged in, and saved when they log in (unregistered when they log out).
App.module:
const cloudSettings: CloudSettings = {
'core': {
'app_id': 'APP_ID',
},
'push': {
'sender_id': 'SENDER_ID',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true,
},
'android': {
'iconColor': '#343434'
}
}
}
};
instead of making push a provider in app module, I made an injectable service that can be used across components. The main app component subscribes to the notifications, while my login and logout components tell it whether or not to register and save them.
export class NotificationService{
token: PushToken;
registered: boolean;
constructor(public push: Push){
}
checkLogin(status){
if(!status){
this.push.register().then((pushT: PushToken) => {
this.token = pushT;
console.log('token saved:'+ this.token);
});
}
}
saveToken(){
this.push.saveToken(this.token);
console.log('token saved');
this.registered = true;
this.startListening();
}
deleteToken(status){
if(status){
this.push.unregister().then(function(){
console.log('token deleted');
return true;
})
}
}
startListening(){
if(this.registered){
return this.push.rx.notification()
.subscribe((msg) => {
alert(msg.title + ': ' + msg.text);
});
}}
getToken(){
return this.token.token;
}
}
I have my sender ID for GCM configured in config.xml and ionic cloud, and my APNS certificate is saved in ionic cloud. So far this works perfectly on android. On iOS it registers the token and saves to the database, but testing on Ionic cloud my iPhone doesn't receive any notifications. Any thoughts?

Getting user app token using react-native facebook SDK

I've gotten facebook login working using the new https://github.com/facebook/react-native-fbsdk, however I can't seem to get the user token which is usually returned in the response. Anyone found a way to get this information? The other SDK's https://github.com/magus/react-native-facebook-login returns it on the login request but the new FB sdk doesn't, and the documentation on the github page doesn't mention it anywhere.
Found the answer after some more digging. You need to use the fbsdkcore to access the user token. Heres how you use it.
var FBSDKCore = require('react-native-fbsdkcore');
var {
FBSDKAccessToken,
} = FBSDKCore;
var Login = React.createClass({
render: function() {
return (
<View>
<FBSDKLoginButton
onLoginFinished={(error, result) => {
if (error) {
alert('Error logging in.');
} else {
if (result.isCanceled) {
alert('Login cancelled.');
} else {
FBSDKAccessToken.getCurrentAccessToken((token) => {
console.log(token.tokenString);
})
}
}
}}
onLogoutFinished={() => console.log('Logged out.')}
readPermissions={[]}
publishPermissions={['publish_actions']}/>
</View>
);
}
});
You don't need a third party module (react-native-fbsdkcore)
The package (react-native-fbsdk) has instructions on it's Github page: https://github.com/facebook/react-native-fbsdk#usage
After you've logged the user in, you can fetch the access credentials as follows:
import { AccessToken } from 'react-native-fbsdk';
AccessToken.getCurrentAccessToken().then(data => {
console.log(data.accessToken.toString())
})

titanium app integration with facebook

Its been a couple of days i started working with titanium and got familiar with the framework. Its really cool framework. Now i am building an app trying to connect with facebook.... I also registered an app on facebook developers and got the id.But it couldnt connect for some reason...
I am getting errors like:
Message: Uncaught TypeError: Cannot set property 'appid' of undefined
My code is as follows:(http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Facebook-property-loggedIn)
// Don't forget to set your appid and requested permissions, else the login button
// won't be effective.
Titanium.Facebook.appid = "xxxxxxxxxxxxxxx";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];
Titanium.Facebook.addEventListener('login', function(e) {
if (e.success) {
alert('Logged in');
}
});
Titanium.Facebook.addEventListener('logout', function(e) {
alert('Logged out');
});
// add the button. Note that it doesn't need a click event or anything.
Titanium.UI.currentWindow.add(Titanium.Facebook.createLoginButton({ top: 50, style: 'wide' }));
and in my tiapp.xml i added below code :
<property name="ti.facebook.appid">XXXXXXXXXXX</property>
<modules>
<module platform="android">facebook</module>
</modules>
one last thing i am using android 2.2 similator... I know i should ask this question in titanium appcelerator forums ... i didn't it, but did get any response ... Thought some geeks here might help me.. Thanks
I am using titanium studio with 3.1 SDK. So i guess Titanium.Facebook has been deprecated in newer versions.http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Facebook.LoginButton)
Below code snippet works for me..
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var fb = require('facebook');
fb.appid = "xxxxxxxxxxxxxxx";
fb.permissions = ['publish_stream'];
fb.addEventListener('login', function(e) {
if (e.success) {
alert('Logged in');
}
});
fb.addEventListener('logout', function(e) {
alert('Logged out');
});
win.add(fb.createLoginButton({
top : 50,
style : fb.BUTTON_STYLE_WIDE
}));
win.open()
Cheers...