I'm trying to implement cordovaAppRate in an Ionic app, i already set the configs, and the dialog box with the options "Remind me later", "Rate now", and "No thanks" is successfully displayed, But when i click the link "Rate now", nothing happens!
I'm testing with an actual device with Android 5.1.1
here's my cordovaAppRate configs
.config( function($cordovaAppRateProvider) {
var preferences = {
language: 'de',
appName: 'MyAppName',
openStoreInApp: false,
androidURL: 'market://details?id=myapp.id',
iosURL: 'myapp.id'
}
document.addEventListener("deviceready", function() {
$cordovaAppRateProvider.setPreferences(preferences);
}, false);
})
This is the function that triggers the dialog box
$scope.rate = function() {
if (typeof AppRate != 'undefined') {
$cordovaAppRate.promptForRating(true);
};
}
any idea of why the "Rate now" link is not working?
Skip the if clause - wrap instead in ionicPlatform.ready() function.
Be sure to know how to implement plugins in the ionic-framework. Some common pitfalls can be read about here: http://ngcordova.com/docs/common-issues/
An alternative is to use this callback:
AppRate.preferences.callbacks.onButtonClicked = function(buttonIndex) {
};
In this function, check what the buttonIndex of "Rate Now" button is (0, 1, or 2), and then use
$cordovaAppRate.navigateToAppStore() to manually navigate to the app store
Related
I'm writing Chrome devtools plugin.
devtools.js
chrome.devtools.panels.create("Override Debug",
null,
"panel.html",
(panel) => {
panel.onShown.addListener(addDebugger);
panel.onHidden.addListener(destroyDebugger);
}
);
So when user navigates to Override Debug tab in devtools, I'm initializing debugger.
When user navigating away from my devtool, I'm discarding debugger - Which is working great
Now the issue comes, when user navigates to Override Debug and closed devtools completely, debugger still alive making page un responsive.
I tried to see events in panel object chrome.devtools objects also tried entire github to see if we have such event. No luck.
Is there any event that monitors devtools close event to discard the debugger I attached?
Update 1
Tried to attach Inspector.enable command as follows but no luck. It never got Inspector.detached message
function addDebugger() {
chrome.tabs.getSelected(null, function(target) {
debuggee = { tabId: target.id };
chrome.debugger.attach(debuggee, "1.2", () => {
chrome.debugger.sendCommand(debuggee, "Network.setRequestInterception", { patterns: [{ urlPattern: '*' }] });
chrome.debugger.sendCommand(debuggee, "Inspector.enable");
});
chrome.debugger.onEvent.addListener((source, method, params) => {
if (source.tabId === target.id) {
if (method === "Network.requestIntercepted") {
// Do many things
} else if (method === "Inspector.detached") {
destroyDebugger();
}
}
})
});
}
I'm trying to put AdMob ads into my ionic android apps and to test the functionality I made an ionic app called AdMobTest. The plugin I'm using is the cordova-admob-pro plugin. Here is my AdMob code:
var admobid = {};
if (/(android)/i.test(navigator.userAgent)) { //Android
admobid = {
banner : 'ca-app-pub-2586564966169402/9782816366',
interstitial : 'ca-app-pub-2586564966169402/8345912938',
gotHereMsg1 : 'banner and interstitial have the android IDs'
};
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { //iOS
admobid = {
banner : 'Stand in iOS banner ID',
interstitial: 'stand in iOS interstitial ID',
gotHereMsg1 : 'banner and interstitial have the iOS IDs'
};
} else { //Neither
admobid = {
gotHereMsg1 : 'banner and interstitial have no IDs'
}
}
if (window.AdMob) {
var admob = window.AdMob;
admob.createBanner ({
adId : admobid.banner,
position : admob.AD_POSITION.BOTTOM_CENTER,
isTesting : false, //False for live ; True for production
autoShow : true
});
admob.prepareInterstitial ({
adId : admobid.interstitial,
autoShow : false
});
gotHereMsg2 = "window.AdMob is true";
} else {
gotHereMsg2 = "window.AdMob is not true";
}
//Got an ID and the actual ID's
document.getElementById("getIdCheck").innerHTML = admobid.gotHereMsg1;
document.getElementById("bannerId").innerHTML = admobid.banner;
document.getElementById("interstitialId").innerHTML = admobid.interstitial;
//window.AdMob is true and banner is created + interstitial is prepared
document.getElementById("isWindowAdmob").innerHTML = gotHereMsg2;
//Show interstitial function is executed or has not been executed
document.getElementById("startInterstitial").onclick = function () {
if (window.AdMob) {
var admob = window.AdMob;
admob.showInterstitial();
gotHereMsg3 = "Show Interstitial function has been executed";
} else {
gotHereMsg3 = "Show Interstitial function has not been executed";
}
document.getElementById("checkInterstitial").innerHTML = gotHereMsg3;
}
To show what works I kept in the tests I did using the "gotHereMsg" variables. All the variables get where I want them to go.
So gotHereMsg1 has the msg about android IDs and the IDs are also correct.
gotHereMsg2 returns "window.AdMob is true" which means the createBanner and prepareInterstitial function are being executed.
Lastly gotHereMsg3 returns "Show Interstitial function has been executed" when I click the button.
Even though all the functions are being executed and it obviously recognizes window.AdMob no banners are being shown. Hopefully this provides enough information to resolve this.
It might be worth noting that I am using ionicv1 and that the code is written in the ionic's app.js file under the $ionicPlatform.ready function.
I have plenty of experience with admob and ionic v1.
First, dont use cordova-admob-pro, they (he?) literally steals revenue from you! tuns of proof here
Use cordova-plugin-admob-free
if (window.admob !== undefined) {
admob.banner.config({
id: 'ca-app-pub-...',
autoShow: true
});
// Create banner
admob.banner.prepare();
// Show the banner
admob.banner.show();
admob.interstitial.config({
id: 'ca-app-pub-....',
autoShow: false
});
admob.interstitial.prepare();
}
Second I don't really see anything wrong...
I'd advise you to run the admob commands in the browser console windows while using remote inspect.....
and at same time watch the adb logcat to see if you get "NO FILL" or any other admob error
First of all, sorry for my english, but I try my best) I have no idea whats wrong with my chrome extension. In background script I create some notifications with action by click on it. Action - open new tab with some link. When I click on the notification at first time - everything is ok, but if I click on the second notification, script open 2 different tabs with first link and with second link. The same situation with 3rd, 4th, 5th .... notification: in the next time script open +1 previous link.
There is a responsible fragment of source code:
var myNotificationID = null;
chrome.notifications.create(
'name-for-notification', {
type: 'basic',
iconUrl: 'yes.png',
title: "CONTENT WAS PUBLISHED",
requireInteraction: true,
message: "Link: " + urlchk,
buttons: [{
title: "GOT IT!"
}]
},
function(id) {
myNotificationID = id;
}
);
//
chrome.notifications.onButtonClicked.addListener(function(notifId, btnIdx) {
if (notifId === myNotificationID) {
if (btnIdx === 0) {
chrome.notifications.clear(notifId);
}
}
});
chrome.notifications.onClicked.addListener(function(notifId) {
if (notifId === myNotificationID) {
chrome.tabs.create({
active: true,
url: urlchk
});
chrome.notifications.clear(notifId)
}
});
I feel I need to clear smth but I don't know what exactly. Thank you for any suggestion.
I have a problem with the back button of my application.
Initially I thought that the problem was in Cordova, but I have identified that the problem is actually in Ionic.
I found this code while researching for a solution:
// Disable BACK button on home
$ionicPlatform.registerBackButtonAction(function (event) {
if($state.current.name=="app.home"){
navigator.app.exitApp();
}
else {
navigator.app.backHistory();
}
}, 100);
However, it is giving the following error:
Uncaught ReferenceError: $ionicPlatform is not defined
I am putting that code within a new document called functionAngular.js and I add it at the end of the body tag. As I must inform this function ?
My problem is that:
I want my back button to send the user further back in the navigation stack instead of closing the application instantly.
I am grateful for this help.
I recommend you first add $ionicPlatform in controller, and in the first controller loaded, test every state (see below) that the back button should have different actions.
$ionicPlatform.registerBackButtonAction(function () {
if ($state.current.name == " login (example) ") {
ionic.Platform.exitApp();
}
if ($state.current.name == " main menu buttons (example) ") {
// Sample message "want to exit the application?" (YES/NO)
if (YES) {
$ionicViewSwitcher.nextDirection('back');
$state.go(' ????');
};
};
if ($state.current.name == " order (example) ") {
// Sample message "want to exit the order?" (YES/NO)
if (YES) {
$ionicViewSwitcher.nextDirection('back');
$state.go(' ????');
};
};
}, 100);
angular.module('EGLISE')
.run(function($ionicPlatform,$state,$ionicHistory){
$ionicPlatform.registerBackButtonAction(function (event) {
if($state.current.name=="app.home"){
navigator.app.exitApp();
}
else {
$ionicHistory.backHistory();
}
}, 100);
});
Please modify your functionAngular.js to the above code.
I'm currently using this implementation to use Browsers based Notifications :
https://developer.mozilla.org/en-US/docs/Web/API/Notification
This works like a charm.
if ("Notification" in window) {
if(Notification.permission === "granted") {
if($('#notify-on-message').is(':checked')) {
var notification = new Notification(username + ' : ' + data, {'icon': "/custom/favicon.gif"});
}
if ($('#notify-on-hl').is(':checked')) {
var patt = new RegExp("(^|\\W)"+selfusername+"(\\W|$)");
if(patt.test(data)) {
var notification = new Notification(username + ' highlighted you.', {'icon': "/custom/favicon.gif"});
}
}
}
}
The main issue I have is that on chrome based browsers, the notification just doesn't close itself after the 3 seconds delay.
It tried adding this after the var notification = ...
setTimeout(function() {
notification.close();
}, 2000);
Though that doesn't change a single thing. The notification remains.
Is it a known issue ? Is there an easy way to fix this behaviour I don't want ?
EDIT 1:
According to this page :
https://developer.mozilla.org/en-US/docs/WebAPI/Using_Web_Notifications
This is a known issue :
Note: Firefox and Safari close the notifications automatically after a few moments, e.g. 4 seconds.
This can also be done at the web application level using the Notification.close() method, for example with the following code:
var n = new Notification("Hi!");
n.onshow = function () {
setTimeout(n.close, 5000);
}
Though that code doesn't work. There is an error in the console that says that the notification doesn't have the close method or something like that.
Well actually I was wrong, the code
var message_notification = new Notification("Data");
setTimeout(function(){
message_notification.close();
}, 3000);
Works in both Firefox and Chrome. (And Safari too I guess)
Adding a tag to the option will close active popup before showing new once
var options = {
body: msg,
icon: "logo.png",
dir: "ltr",
tag: "group1"
};