Ionic Push on Android: unexpected error occured - angularjs

I'm trying to use Ionic Push notifications on android, but every time I got the following error:
Ionic Push:, (debug) unexpected error occured.
Ionic Push:, [object Object]
I'm using Genymotion as my emulator, with Google Play Services installed (https://stevenkideckel.wordpress.com/2014/12/27/how-to-install-google-play-services-on-genymotion/). Testing on a real device is not working as well.
Also, I'm using this push plugin (https://github.com/phonegap/phonegap-plugin-push), and installed like this:
ionic plugin add phonegap-plugin-push --variable SENDER_ID="my-gcm-project-number"
My push code look's like this:
var push = new Ionic.Push({
'debug': true,
'pluginConfig': {
'android': {
'senderID': 'my-project-number',
'iconColor': '#343434'
}
}
});
push.register(function(token) {
console.log('Device token:', token.token);
push.saveToken(token);
});
I already configured my Ionic app using:
ionic config set dev_push false
ionic push --google-api-key my-google-api-key
ionic config set gcm_key <my-gcm-project-number>
I tried to search for similar problemas but never found a solution.
Anyone can help me?
Thanks!

To answer my own question:
When I published my app and testing on a real Android device downloading the app from Google Play, it worked.
A few things to try if you are getting this problem:
Remove and add again the push plugin:
ionic plugin remove phonegap-plugin-push
ionic plugin add phonegap-plugin-push --variable SENDER_ID="my-gcm-project-number"
Also:
Generate a new project number and API key on Google Console;
Check .io-config.json to check if your keys and numbers are correct;
Make sure your dev push is off: ionic config set dev_push false;
Set your GCM key on Ionic IO: ionic config set gcm_key <your-gcm-project-number>;
Check (and make it again if needed) your build profiles on Ionic IO;
Also check this answer: https://forum.ionicframework.com/t/ionic-push-not-working-on-android/52636/2
Hope this help someone.

Related

RNIap.getProducts(itemSku) returns empty array

I am using the package react-native-admob
I created an alpha track of my app and created a managed product on the play console
If I try
RNIap.prepare()
I get the error
RNIap.prepare is not a function. (In 'RNIap.prepare()', 'RNIap.prepare' is undefined)
if I try
const itemSkus = Platform.select({
ios: [
my_product_id
],
android: [
my_product_id
]
});
const products = await RNIap.getProducts(itemSkus);
console.log(products)
I get
Array []
Is there any additional setup I'm missing? This is my first time working with in-app-purchases on react-native
I have been following along with this tutorial, but run into problems when I get to RNIap.prepare(). My app was using the Expo managed workflow, and is now using the bare workflow. I am still running my app with expo start, because I don't know what else I can do to run it.
Have you followed these steps in the document rn-iap? This was the document which i followed and implemnted in app purchase for both android and ios in react native. It explains easily and beautifully. Do check it out.
ps: Even my app is in production and it has succesfull in app purchase
You can't get RNIap.prepare() in android before first release in Google Play Store
The answer was actually that I had a different bundle id for the app on the Google Play Console than I did in all my files. Expo chose this other bundle id for me as com.myAppName.
Because the play console does not allow you to change the bundle id I had to search for com.myAppName everywhere in my project and change it to the bundle id I had entered in on the google play console.
RNIap.prepare() is apparently not even a function anymore, but it is true that you must publish a release in the Google Play Store before enabling IAP, but you can publish a Beta.

UPI Deeplinking from IONIC to BHIM - Ionic1 (WebIntent)

Currently I am working on a Project which is implemented in Ionic 1 and AngularJs.
Now we are working to integrate it with BHIM UPI to perform In-App payment. I think we need to install IONIC Native Web Intent plugin in order to make web intent call to BHIM.
But I am fairly new to angularJs and Ionic. I have seen some of the questions related to this but those are implemented in Ionic3 and latest versions.
UPI Deeplinking from IONIC to GooglePay does not work as expected
DEEPLINK_HOST in ionic deeplink
Deeplinking - Opening an Ionic App through another Ionic App
I have tried to achieve this by making Web Intent calls with help of this https://www.npmjs.com/package/#ionic-native/web-intent?activeTab=readme but with no luck. It's giving Error message like below
ionic.bundle.min.js:150 Error: [$injector:unpr] http://errors.angularjs.org/1.5.3/$injector/unpr?p0=webIntentProvider%20%3C-%20webIntent%20%3C-%20PaymentComponent%20%3C-%20PaymentComponent
at http://localhost:8100/js/ionic.bundle.min.js:40:416
at http://localhost:8100/js/ionic.bundle.min.js:77:7
at Object.d [as get] (http://localhost:8100/js/ionic.bundle.min.js:74:270)
EDIT :
I want to open BHIM UPI app from my Ionic App and able return success or failure status of transaction.
Any help or directions to achieve this will be highly appreciated.
There is no 'webIntentProvider' exists in ionic providers.
You've to remove 'webIntent' from your controllers injections. And use below code to open existing UPIs available in your mobile.
window.plugins.intentShim.startActivity(
{
action: window.plugins.intentShim.ACTION_VIEW,
url: urlIntent
},
function () { },
function () {
alert('Failed to open URL via Android Intent')
}
);
It'll show all available UPI providers which are installed in your mobile. Please go through documentation Deeplinking UPI for more details.
Cross check your package.json & confilg.xml, whether you installed above plugin in your app or not.

Using clevertap-react-native npm package, iOS push notification not working

We are using:
react-native - 0.51.0 and
clevertap-react-native - 0.2.1
Here https://www.npmjs.com/package/clevertap-react-native we followed all the instructions and SDK integration steps for ios.
Also added Clevertap.registerForPush(); in root file of project. But still Mobile push notification are not getting enabled in Clevertap Dashboard.
Here you can see, Mobile Push Notification in Clevertap Dashboard
Can you verify once that you've enabled the support of the push notifications for your application?
You can check the same by following steps:
In Xcode, go to your Targets, under your app’s name, select Capabilities and find Push Notifications in the list, switch to ON
Helping Link: https://help.apple.com/xcode/mac/current/#/devdfd3d04a1
Hey this issue has resolved. There was firebase configuration code in my appDelegate.m because of that FCM token was getting generated.
After removing firebase code from AppDelegate.m; iOS push notification working.

Not getting token from ionic push.register when debug mode is false

I am implementing push notification in my ionic app.
I have setup initial steps successfully. In mu debug mode When I use this code:
$ionicPlatform.ready(function() {
var push = new Ionic.Push({
"debug": true,
"onNotification": function(notification) {
var payload = notification.payload;
console.log(notification, payload);
}
});
push.register(function(token) {
alert("Hello");
console.log("Device token:",token.token);
});
});
I have already run this command:
ionic config set dev_push true
I am getting device token value and receiving push successfully.
But when I run this command
ionic config set dev_push false
and put "debug": true, I am not receiving any token.
I have successfully uploaded the .p12 file in Online Acccount of ionic.
If you set dev_push false. You won't get a notification.
Reason.
The variable is named as development_push meaning it is to be used in development mode only. Which means you are on a laptop/PC and testing the API in development mode. But if you switch to, development_push = false then it means you ain't testing on a system anymore and you need to put that .apk or ios equivalent in your phone and test it out in the real world.
So If I were you.
I would set it to false
Build my application.
and install the app in my phone.
and see if it works.
Hope it helps
After spending one complete day. I found one simple solution.
I don't know whether it will work for others or not. But still I am posting may be it helps someone.
After changing:
ionic config set dev_push true
to
ionic config set dev_push false
You have to first remove the Platform whether it is iOS/Android.
ionic platform rm ios/androind
Then add again and build your project. Now it will work for sure.
ionic platform add ios/android
ionic build ios/android

Cannot find hostname in file:/// error when using Ionic and OAuth.io

I am using Ionic and Oauth.io to perform authentication. If I run ionic serve and include the outh.js file in my index everything works good from the browser.
But when I run ionic run ios or install the app in android, I get the following error when I press the auth button (the one that suppose to execute OAuth.popup
I do not know what to do, until now I have checked the following:
In config.xml I have access, allow-intent and allow-navigation full permisive
I have installed and re-installed the plugin ionic plugin add https://github.com/oauth-io/oauth-phonegap.git
I tried to run the native app without the inclusion of the oauth.js file and everything breaks.
Using current versions up to date.
I am new to Ionic, so I don't know how to debug the device-running app or simulator.
Could be similar to this post but not exactly .
Your advices will be appreciated.
I figure it out reading some posts. The OAuth initialization and references should be done after the device is ready, so it is best to put the initialize in this block:
$ionicPlatform.ready(function() {
// ...
if(typeof window.OAuth !== 'undefined'){
$rootScope.OAuth = window.OAuth;
$rootScope.OAuth.initialize('XXX');
}
else{
console.log("plugin not loaded, this is running in a browser");
$.getScript( "lib/oauth.js", function() {
$rootScope.OAuth = OAuth;
$rootScope.OAuth.initialize('XXX');
});
}
});
Now, if the plugin is loaded it initializes the window.OAuth object, else the app is running in browser, so I have to include the oauth.js file. Also I assigned the OAuth to the $rootScope for quick access.
Hope this helps anyone.

Resources