Ionic admob implementation using floatinghotpot cordova-plugin-admob - android

I'm following this tutorial for having banner ads in my android application.
https://blog.nraboy.com/2014/06/using-admob-ionicframework/
The problem is that I get an error callback from the plugin which is only telling me :
Invalid action
I ran the cordova plugin add for the plugin, I modified the admob publisher id, I used the sample code from the tutorial right above but it always get stuck in the second callback function which is the error case callback.
Here is the code I used :
var admobApp = angular.module('myapp', ['ionic'])
.run(function($ionicPlatform, $ionicPopup) {
$ionicPlatform.ready(function() {
if(window.plugins && window.plugins.AdMob) {
var admob_key = device.platform == "Android" ? "ANDROID_PUBLISHER_KEY" : "IOS_PUBLISHER_KEY";
var admob = window.plugins.AdMob;
admob.createBannerView(
{
'publisherId': admob_key,
'adSize': admob.AD_SIZE.BANNER,
'bannerAtTop': false
},
function() {
admob.requestAd(
{ 'isTesting': false },
function() {
admob.showAd(true);
},
function() { console.log('failed to request ad'); }
);
},
function() { console.log('failed to create banner view'); }
);
}
});
});

Related

Launch an external app from an App

I am creating an android APP using Ionic framework,I want to launch an external app from my app.
I included the acces-orgin in the config.xml
<access origin="speedtest:*" launch-external="yes"/>
I am using the following code
<button class="button button-positive" ng-click="btnClick()"> Launch Speed Test</button>
In My app.js
function onDeviceReady() {
var scheme;
// Don't forget to add the org.apache.cordova.device plugin!
if(device.platform === 'iOS') {
scheme = 'speedtest://';
}
else if(device.platform === 'Android') {
scheme = 'org.zwanoo.android.speedtest';
}
$scope.btnClick = function() {
appAvailability.check(
scheme, // URI Scheme
function() { // Success callback
window.open('speedtest://', '_system', 'location=no');
console.log('Speedtest is available');
},
function() { // Error callback
//alert("not available");
window.open('https://play.google.com/store/apps/details?id=org.zwanoo.android.speedtest', '_system', 'location=no');
console.log('Speedtest is not available');
}
);
}
}
the following line is not working and it does not throw any error in the console.
window.open('speedtest://', '_system', 'location=no');
Please guide me .
You can start an external application using third party plugin. Please follow the link below
Plugin for check or launch other application in android device
e.g.
Check application for installed
navigator.startApp.check("com.application.name", function(message) { /* success */
console.log(message); // => OK
},
function(error) { /* error */
console.log(error);
});
Start external application
navigator.startApp.start("com.application.name", function(message) { /* success */
console.log(message); // => OK
},
function(error) { /* error */
console.log(error);
});

cordova facebook plugin login error on android

I have a problem that I couldn't figure out!(I'm, kinda new at this though)
I am trying to run a cordova app on android platform(using a Mac and eclipse-luna), the build is successful, but when I'm trying to login with facebook nothing happens and I get this error in the LogCat:
"Uncaught ReferenceError: facebookConnectPlugin is not defined"
I tried everything I could think of(including lots of posts here at stackoverflow) and nothing solved it.
I would really appreciate any help!
the js code -
var facebookLogin=function()
{
var fbLoginSuccess3 = function (userData)
{
var str=JSON.stringify(userData);
var id=userData["authResponse"].userID;
$.mobile.loading('show');
var promise = $.ajax({
type: 'GET',
url: "https://graph.facebook.com/"+id+"? fields=first_name,last_name,email,picture.width(450).height(450)&access_token="+userData["authResponse"].accessToken,
dataType: 'json'
});
promise.fail( function() {
$.mobile.loading('hide');
});
promise.done( function(result)
{
//alert(JSON.stringify(result));
var first_name=result.first_name;
var last_name=result.last_name;
var email=result.email;
var profileImgUrl=result.picture.data.url;
String.prototype.replaceAll = function(str1, str2, ignore)
{
return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g,"\\$&"),(ignore?"gi":"g")),(typeof(str2)=="string")?str2.replace(/\$/g,"$$$$"):str2);
}
profileImgUrl=profileImgUrl.replaceAll("&","^");
//alert(id+" "+first_name+" "+last_name+" "+email+" "+profileImgUrl);
facebookLoginHandler(id,first_name,last_name,email,profileImgUrl);
});
}
//alert("before login");
facebookConnectPlugin.login(["public_profile","email"],fbLoginSuccess3,function (error) { alert("" + error) });
}
cordova_plugins.js -
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/com.phonegap.plugins.facebookconnect/facebookConnectPlugin.js",
"id": "com.phonegap.plugins.facebookconnect.FacebookConnectPlugin",
"clobbers": [
"facebookConnectPlugin"
]
},
module.exports.metadata =
// TOP OF METADATA
{
"com.phonegap.plugins.facebookconnect": "0.11.0",
"org.apache.cordova.camera": "0.3.4",
"org.apache.cordova.inappbrowser": "0.5.4",
"org.apache.cordova.splashscreen": "0.3.5",
"org.apache.cordova.file": "1.3.3",
"org.apache.cordova.file-transfer": "0.5.0"
}
// BOTTOM OF METADATA
});

Import sip client module to appcelerator error

I'm trying to implement SIP client call to accelerator project. After a few hours of Googling, I decided to use TISIPCLIENT .
So I imported the module to my project. But now I am facing one big problem. I keep getting the error createSipclient method not found.
Here is my code:
var sipclient = require("com.yydigital.sipclient");
var sip = sipclient.createSipclient({
// Events
onregistering : function() {
//callback
}, onregisterationfailed : function() {
//callback
}, onregistrationdone : function() {
//callback
}, oncallestablished : function() {
//callback
}, oncallended : function() {
//callback
}, onincomingcall : function(e) {
//callback
}, onringingback : function() {
//callback
}, oncallbusy : function() {
//callback
}, onerror : function(e) {
//callback
}
});
What could be the cause of the error and how do I fix it?
By seeing your error "createSipclient method not found."...
It seems like the module is not able to locate the proxy. Try to rebuild the module and use it, this will definitely solve your problem since i had faced many times the same error and i did the same to solve the issue.
Let me know if that works else we will look in other way.

ionic framework parse push notifications device not registered

I'm trying to get parse push notifications to work on my android device. I have done the GCM setup and tested it with urbanairship. It works.
But for some reasons I need to get it to run with parse.
What I have done so fare...
in my $ionicPlatform.ready function I initialize the parse plugin like this:
window.parsePlugin.initialize(
"XXX",
"XXX",
function() {
alert( 'PARSE INIT OK' );
window.parsePlugin.getInstallationId(function(id) {
installationID = id;
}, function(e) {
console.log("Error Getting ID: " + e.code + " : " + e.message);
})
},
function( e ) {
alert( 'PARSE FAILED' );
});
});
In my HelloCordova.java files onCreate function I added this:
Parse.initialize(this, "XXX", "XXX");
PushService.setDefaultPushCallback(this, HelloCordova.class);
ParseAnalytics.trackAppOpened(getIntent());
ParseInstallation.getCurrentInstallation().saveInBackground();
I followed the Parse Android instructions to modify my AndroidManifest.xml.
And I added the parse and phonegap notification plugin to the project.
cordova plugin add https://github.com/avivais/phonegap-parse-plugin
But I can't register the device for Parse notification.
i also tried so many times on this. iOS did work but not android. but after i installed this plugin it worked.
https://github.com/avivais/phonegap-parse-plugin
Use this in app.js and it did work.
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
try{
parsePlugin.initialize('xxx', 'yyy', function() {
alert('success');
}, function(e) {
alert('error');
});
}catch(err){
alert('Parse Error '+err.message); //this gets executed all time
}
});
})

Phonegap facebook plugin: Not working when native FB app is installed

I have used cordova- 2.5.0 & facebook-sdk 3.0.2 in fb plugin.It works fine when device does not have native app installed. when native app is installed nothing is happened.means it cant get current access token of user.Any idea? According to me there are two ways:
1) disable to get access native app just like in ios. But its not right way as if user is allready login in native then he has to login again in my plugin setup.
2)dont know how to solve this issue.There is no issue with hash key as it is right and works well in ios using my first way.
So my question is that how to prevent to accessing native app? OR Is there any other way to solve this issue?
As i dont get anything. when i am going to get user's friend list it shows An active access token must be used to query information about the current user.,"type":"OAuthException","code":2500.
cdv-pluggin-fb-connect.js
CDV = ( typeof CDV == 'undefined' ? {} : CDV );
var cordova = window.cordova || window.Cordova;
CDV.FB = {
init: function(apiKey, fail) {
// create the fb-root element if it doesn't exist
if (!document.getElementById('fb-root')) {
var elem = document.createElement('div');
elem.id = 'fb-root';
document.body.appendChild(elem);
}
cordova.exec(function() {
var authResponse = JSON.parse(localStorage.getItem('cdv_fb_session') || '{"expiresIn":0}');
if (authResponse && authResponse.expirationTime) {
var nowTime = (new Date()).getTime();
if (authResponse.expirationTime > nowTime) {
// Update expires in information
updatedExpiresIn = Math.floor((authResponse.expirationTime - nowTime) / 1000);
authResponse.expiresIn = updatedExpiresIn;
localStorage.setItem('cdv_fb_session', JSON.stringify(authResponse));
FB.Auth.setAuthResponse(authResponse, 'connected');
}
}
console.log('Cordova Facebook Connect plugin initialized successfully.');
}, (fail?fail:null), 'org.apache.cordova.facebook.Connect', 'init', [apiKey]);
},
login: function(params, cb, fail) {
params = params || { scope: '' };
cordova.exec(function(e) { // login
if (e.authResponse && e.authResponse.expiresIn) {
var expirationTime = e.authResponse.expiresIn === 0
? 0
: (new Date()).getTime() + e.authResponse.expiresIn * 1000;
e.authResponse.expirationTime = expirationTime;
}
localStorage.setItem('cdv_fb_session', JSON.stringify(e.authResponse));
FB.Auth.setAuthResponse(e.authResponse, 'connected');
if (cb) cb(e);
}, (fail?fail:null), 'org.apache.cordova.facebook.Connect', 'login', params.scope.split(',') );
},
logout: function(cb, fail) {
cordova.exec(function(e) {
localStorage.removeItem('cdv_fb_session');
FB.Auth.setAuthResponse(null, 'notConnected');
if (cb) cb(e);
}, (fail?fail:null), 'org.apache.cordova.facebook.Connect', 'logout', []);
},
getLoginStatus: function(cb, fail) {
cordova.exec(function(e) {
if (cb) cb(e);
}, (fail?fail:null), 'org.apache.cordova.facebook.Connect', 'getLoginStatus', []);
},
dialog: function(params, cb, fail) {
cordova.exec(function(e) { // login
if (cb) cb(e);
}, (fail?fail:null), 'org.apache.cordova.facebook.Connect', 'showDialog', [params] );
}
};
Thanks in Advance!!
I was able to get it working with this plugin: https://github.com/jimzim/phonegap-facebook-android-sample

Categories

Resources