Initialization Android In App Billing using cordova plugin - android

In My ionic Cordova Application, I am using In App Purchase Plugin: https://github.com/j3k0/cordova-plugin-purchase
Here is the method that I use to initialise store:
storekit.init({
debug: true, // Enable IAP messages on the console
ready: service.IAP.onReady,
purchase: service.IAP.onPurchase,
restore: service.IAP.onRestore,
error: service.IAP.onError
});
This Initialization works fine with iOS and all the products loading fine as well, But Android device does not load In Purchase.
I guess, For android there is a different initialization method.
I have added plugin in app:
cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="<BILLING_KEY>"
Please help.

Firstly, when I was using it, the npm version was a little buggy on android. Try removing it and adding it from Git.
cordova plugin add https://github.com/j3k0/cordova-plugin-purchase.git --variable BILLING_KEY="MIIB...AQAB"
Secondly, it looks like you are maybe using some older syntax. The doco for this plugin doesnt really have very good version control. There are different versions of doco all over the net. I think this is the latest version.
This is my initialisation code. See if it works for you too.
products = ["my.test.product"];
for (var i = 0; i < products.length; i++) {
if (window.store) {
store.register({
id: products[i],
alias: 'alias '+i,
type: store.NON_CONSUMABLE
});
}
}
// When everything goes as expected, it's time to celebrate!
if (window.store) store.ready(function() {
console.log("\\o/ STORE READY \\o/");
});
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
if (window.store) store.refresh();
You can also send the store object to console.log to have a good look at it in chrome debugger.
Oh, and if you have more than one app, make sure you are using the correct BILLING_KEY by removing and readding the plugin.
Good Luck!

Related

Expo build apk : ExponentToken not generated

I created my first expo app, who can send notification to multiple users. I use the expo-notification package to generate the ExponentToken and handle incoming notification.
Everythings works perfecly when I use the expo go app, but recently I build my app in apk with eas
$ eas build -p android --profile genAPK
//the genAPK profile :
build: {
"genAPK":{
"android": {
"buildType":"apk"
}
}
}
I downloaded the builded apk, but when my real app want to generate the ExponentToken it just not works and return me a empty string... (I know it because my app crash do a alert() if the token is empty)
I don't know if this help, but I dont use the firebase way, I use the expo node sdk and my own database and API to store tokens and send notifications
Is this a common mistake and how can I fix this ?
Or at least can I see the output of my package even if this is a apk ?
Thanks in advance
My notification is also not working when i upgrade to EAS.
And i found this in Expo discord group:
No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.
at http://192.168.7.186:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:102608:321 in _createSuperInternal
at node_modules/expo-modules-core/build/errors/CodedError.js:10:8 in constructor
at http://192.168.7.186:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:313197:49 in getExpoPushTokenAsync$
There is a problem with ExpoPushToken, and you can see the source of this error from here expo-notifications-repo. The cause of this error in my case is the projectId, because in the expo-notifications-repo they use expo-constant package which have change in the latest SDK. So i need to add projectId to my app.json
"extra":{
"eas":{
"projectId":"(PROJECT_ID-Expo.dev)"
}
}

Basic usage of #react-native-firebase/admob gives: "TypeError: (0, _admob.default) is not a function". Is it deprecated? or Why doesnt work?

Is #react-native-firebase/admob deprecated? or just.. Why it doesn't work?
I am using #react-native-firebase/admob (https://rnfb-docs.netlify.app/admob/usage).
Everything works fine before to use "admob()". When I add admob() to the code appears this error:
"TypeError: (0, _admob.default) is not a function"
Do someone know why?
My code below (basic usage):
import React from 'react';
import { Text, View} from 'react-native';
import admob, { MaxAdContentRating } from '#react-native-firebase/admob';
import { InterstitialAd, RewardedAd, BannerAd, TestIds } from '#react-native-
firebase/admob';
import { BannerAdSize} from '#react-native-firebase/admob';
class App extends React.Component{
componentDidMount(){
// this was taked of official page: https://rnfb-docs.netlify.app/admob/usage#installation
admob()
.setRequestConfiguration({
// Update all future requests suitable for parental guidance
maxAdContentRating: MaxAdContentRating.PG,
// Indicates that you want your content treated as child-directed for purposes of COPPA.
tagForChildDirectedTreatment: true,
// Indicates that you want the ad request to be handled in a
// manner suitable for users under the age of consent.
tagForUnderAgeOfConsent: true,
})
.then(() => {
// Request config successfully set!
});
}
render(){
return(
<View style={{
alignItems:"center",
justifyContent:"center",
height:"100%"}}>
<Text style={{color:"black"}}>
Hola
</Text>
<BannerAd
unitId={TestIds.BANNER}
size={BannerAdSize.FULL_BANNER} />
</View>
)
}
}
export default App;
Despite #CodeJoe Answer, I still got confused by different Documentations for the React Native Firebase that where around, hence I spend lots of time and energy to get around it.
I open an issue here where is confirmed that Google removed the AdMob Package since v11.5.0.
AdMob is no longer in Firebase APIs, so this module no longer wraps it, there is no documentation to correct.
However it did exist as recently as v11.5.0 here and if you browse the repository at that point, you may consider the e2e tests for AdMob at the time a primer on "How To Use AdMob" https://github.com/invertase/react-native-firebase/tree/0217bff5cbbf233d7915efb4dbbdfe00e82dff23/packages/admob/e2e
Please, don't be like me and check the correct Documentation and website:
Correct
https://rnfirebase.io
Wrong Wrong Wrong, this refers to an older verison
https://rnfb-docs.netlify.app
The internet has a long memory, so there are stale copies of the docs out and about yes, but rnfirebase.io is always the official and current doc site
Admob was removed completely from the firebase ecosystem by Google so it does not exist here no. There are some community packages for it, our v11.5 version that has it, and we hope to peel our implementation out and update it for the community but it takes time and we are unfortunately still backlogged on official firebase apis, so it has not happened yet
So for AdMob solution I would use another Library, and use react-native-firebase for the Solutions that they currently provide
Alternative Library (August 2021)
DISCLAIMER
React Native Firebase is a great library still for the other packages they provide (Firebase, Analitycs...) and the Admob version 11.5 is still a solution. These are just suggestion for alternatives for Admob.
react-native-admob-alpha Simple and fresh library, recently updated.
react-native-admob-native-ads Another brand new library, they implement Admob Native Advanced Ads.
Expo AdMob (Available also for bare React-Native Projects)
To complete your searching I'll add that Admob is removed from React Native Firebase and there is no plan to implement it again. Only re-host code on an external repository.
Last supported version is 11.5.0
It means if you would like to use RN Firebase Admob before re-host you need to use all other services (like RNF analytics) with this version.
For more info please check https://github.com/invertase/react-native-firebase/issues/5329#issuecomment-843272057
Remember to use
dependencies{
"#react-native-firebase/admob": "11.5.0",
"#react-native-firebase/app": "11.5.0",
}
instead of
dependencies{
"#react-native-firebase/admob": "^11.5.0",
"#react-native-firebase/app": "^11.5.0",
}```
I could solve it.
SOLVED
Just check in the file "package.json" that packages of firebase has the same version, example:
dependencies{
"#react-native-firebase/admob": "^11.5.0",
"#react-native-firebase/app": "^11.5.0"
}
TIP
Works to similars errors.
I am able to use 11.5.0 downgrade trick in react native 0.65.1 for my RewardedAds. I edited the package.json file as said. It didn't work but I managed to run it in a different way:
Close any running react-native related terminals. Uninstall #react-native-firebase/app.
npm uninstall #react-native-firebase/app
Install the #react-native-firebase/app version 11.5.0 directly with this command.
npm install #react-native-firebase/app#11.5.0
After the installation, go to package.json>dependencies and do both packages versions the same(11.5.0) and remove ^.
"#react-native-firebase/admob": "11.5.0",
"#react-native-firebase/app": "11.5.0",
Start the react-native with fresh cache then run-android.
npx react-native start --reset-cache
npx react-native run-android

include.gradle file being generated is causing problems

When building a project I get the following error:
Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
It happens only when using the pro version through the #progress registry. Doesn't happen with the local .tgz pro version.
I noticed the error has to do with the include.gradle file it generates. I read the following article: https://docs.nativescript.org/plugins/plugins#includegradle-specification
It says that when the plugin doesn't have the include.gradle, at build time gradle creates a default one with default elements. When I saw the include.gradle it generated for the plugin it seems to have generated a default one like so:
android {
productFlavors {
"nativescript-telerik-ui" {
dimension "nativescript-telerik-ui"
}
}
}
The include.gradle generated for the local .tgz version of the plugin is like this:
android {
productFlavors {
"F6" {
dimension "nativescripttelerikuipro"
}
}
}
I replaced the default include.gradle with the latter and it got past the error. You can recreate the problem by following these steps:
create a new hello world app
use the command npm login --registry=https://registry.npm.telerik.com/ --scope=#progress to log in if you're a paying customer.
use the command npm install --save #progress/nativescript-telerik-ui-pro to install the plugin
use tns run android
Is there anything I can do to solve this problem? Really need help on this.
My name is Vladimir and I am part of the nativescript-telerik-ui-pro team. Thank you for logging this issue in our feedback portal. We are going to review it as soon as possible and update you regarding its status, but from what I currently see there is some incorrect "parameters" passed to the 'pro' version of the plugin that are going to be resolved very fast.
We apologize for any inconvenience that this is causing.

$cordovaDatePicker not working after android build

I have written an android app using Ionic. The app uses $cordovaDatePicker from the ngCordova website, and this works fine when I do ionic run android and install the app onto my phone.
The problem is if I run ionic build android, then install the apk from a website to test it in the real world, the datepicker doesn't show at all. The function it's in is being called fine, and if I console.log $cordovaDatePicker then I can see an object is output as I'd expect.
The function I am calling looks like this:
var options = {
date: new Date(),
mode: 'date'
};
$cordovaDatePicker.show(options).then(function(date) {
$timeout(function() {
scope.selectedDateTime = date;
}, 50);
}, function(err) {
alert(err);
});
I've tried adding every permission from this page and that still didn't help. Because the datepicker window is never shown, neither the success or error callbacks are reached. Does anyone have any ideas?
Thanks for any help.
Got this working in the end by:
Upgrading Ionic to the latest version via npm
Removing the datepicker plugin (v0.8.1)
Installing it again with the latest version (v 0.8.9)
Not sure what changed but it's working OK now!

cordova 1.6.1 android Uncaught TypeError: Cannot call method 'showWebPage' of undefined

i just upgraded phonegap 1.4.1 to 1.6.1 and also upgraded the child browser from https://github.com/libbybaldwin/phonegap-plugins/tree/master/Android/ChildBrowser
and i have added this line in plugins.xml file
<plugin name="ChildBrowser" value="com.phonegap.plugins.ChildBrowser.ChildBrowser"/>
but when i calling this
window.plugins.childBrowser.showWebPage( "http://google.com", {
showLocationBar: true
});
i am geting this error Uncaught TypeError: Cannot call method 'showWebPage' of undefined
Concerning the 1.4.1 vs 1.6.1:
Please be aware that my github repo of phonegap-plugins is what I "froze" in internet time to allow continued use of phonegap 1.4.1 with plugins from that era.
Moving forward to cordova 1.6.1+ you'll need to move on the the official unofficial plugins at
https://github.com/phonegap/phonegap-plugins
Note: These plugins may or may not be updated work with cordova 1.6.1. Please read their individual README's and the blog below from a phonegap engineer:
http://simonmacdonald.blogspot.com/2012/04/migrating-your-phonegap-plugins-to.html
Summary: moving from 1.4.1 to 1.6.1+ and using phonegap plugins will require some vigilance as there were many changes internally between those two versions.
I was able to solve this error by using this code:
try {
var cb = new ChildBrowser();
console.log(cb);
cb.showWebPage('http://www.google.com');
}catch (err){
console.log(err);
}
Although this caused another error:
PhoneGap Build + Cordova + ChildBrowser Error
If you don't get any errors and this solution works - please let me know!
Have been fighting this same error for some days now and found that you can not call the childBrowser right away from your index.html, likely because the initialization of the childBrowser plugin takes some time to complete.
This solution works:
setTimeout(function() {
window.console.log('Opening Childbrowser...');
window.plugins.childBrowser.showWebPage("http://www.google.com", { showLocationBar: true });
}, 3500);
In other words: you have to wait for the childBrowser object to become available, there are more elegant solutions thinkable of course.
DISCLAIMER: tested with the current 1.7.0rc1 Cordaova release, not sure if this works for 1.6.1 as well.

Categories

Resources