I'm trying to use FCM push notifications with my Ionic 2 app via cordova-fcm-plugin.
I've followed every tutorial and it's working fine when i send a push from the firebase console, but i want to do some stuff in my app using its functionalities and the payload, but when i try to use any method from the plugin i get a Cannot find name 'FCMPlugin' error on Visual Studio:
The error
I've been looking for how to use it correctly and haven't found anything, just this question: The Question
So what is the correctly way to implement and use the plugin? Is there a module? I can call it from the 'ionic-native'? I have to import it from somewhere? Just use the plugin .js file link in the index.html? Or this error is commom and in emulation/building it'll work fine?
Thanks :D
PS: I've not tryed to build it or emulate it to see what happens, going to do this now.
EDIT
Ok, so it's an error that won't let me build my app. Rly need to know how to use the plugin now.
You have to declare the FCMPlugin variable after your imports:
import { Foo} from '../pages/foo/foo';
import { Bar } from '../pages/bar/bar';
declare var FCMPlugin: any; // <---- this is the magic line
Related
I had been working on a project that uses Firebase Authentication.
Everything worked fine until I updated to Flutter 2.
Now it's telling me that "User" isn't a type. I can't find anything in their changelog that might have caused this error.
splashScreenFunction: () async {
//// check if login
User result = FirebaseAuth.instance.currentUser;
print("User: $result");
if (result != null)
return mainPage(userID: result.uid,);
else
return LoginPage();
},
Here's an example of one of the parts in my project that is giving me an error. This specific part is where I check if the user is logged in by trying to fetch the User ID.
In other parts of the code I am using similar ways in order to obtain the user ID. What is the new way of doing this?? Did i miss something?
I can't seem to find any information as this is a somewhat new update.
try prefixing firebase_auth import (like firebase_auth)
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
.
.
.
//Change
firebase_auth.User result = firebase_auth.FirebaseAuth.instance.currentUser;
The problem seems to have been caused by dependencies not having been well updated to support null-safety. I used this guide to make sure that everything was migrated properly, and then it worked again.
So basically it wasn't working because I updated Flutter and Dart, but didn't make sure that all the packages were updated to support null safety.
For future reference: not all of your previously used packages will support null safety(unless they have been updated to do so), but for some reason unknown, you can still use them in your project regardless. I also noticed there's quite a few packages that have not been updated, but users have created new versions of them called "another_[packageNameHere]" and it will usually work the same way. If you don't update your packages to use null safety you will get a rain of deprecation warnings.
I am sending push notification using firebase console and i am getting "0% of potential users are eligible for this campaign: 0". and push notification is not displaying in mobile..If anyone got same experience and solve issue then please suggest me how can i solve this issue. I followed all the thing..that i added json file that i got from firebase.
Please check for the following:
Have you configured your android package name correctly.
Did you place the google-services.json file in android/src folder.
Make sure you have done all steps present in this link (If you using android studio i suggest going with option 2)
Get user token to send firebase message Follow the steps
After all these if you still can't receive push notifications try setting channelid in advanced messaging options
Refer https://firebase.google.com/docs/cloud-messaging/android/client link step by step and you will be good to go for your push notification using fcm and if you already implemented the basic things then compare your code with the sample code step by step mentions on the link. you must find out the error. let me know if it resolves your issue.
Go to Build --> clean project -->Rebuild project
(Build is at top in android studio)
Why it was not working - You must have had deleted google-services.json file and re-added it.
Make sure you have only one firebase project configured for this app (if no then delete one you dont plan to use)
Go to firebase setiings -> Left top angle -> settings icon -> Project settings ->
scroll to bottom, then make sure to add SHA certificate fingerprints Type. How to get it
Then (still on this page) press See SDK instructions button. And place google-services.json file in your project.
If all this steps passed for you and you still getting this error then just wait a little bit, for me it take 2 days, before it started working.
I was asked to develop a sample app integrated with Amazon Pinpoint. Since I am not a pro at developing apps, I decided to follow this simple tutorial and develop the app following the steps described in it. The only differences are that, instead of using an emulator, I executed the project in my own cell phone (a Xiaomi Redmi 4x) and instead of GCM, I used Firebase.
At first, it seemed to work perfectly, but when I moved the app to the background and went back to my homescreen, I could no more receive push notifications from my app. When the app is open and running, everytime I send a push notification a pop-up appears with Title "New Notification" and buttons "Ignore"/"View". But when in background, nothing is visible in my system tray!
Also, if someone knows which part of the code is responsible for this notifications, just warn me and I upload it here.
Okay, so after some tests I made it work (not through console, but through CLI). To do so, I followed some steps I found this question, that took me to two other documents: one from Amazon teaching how to send push notifications through CLI and a simple but very detailed tutorial of phonegap-plugin, the plugin used in our Ionic application to process the pushes.
First of all, replace the phonegap-plugin in your app with the master version avaliable in the github link I sent you.
Then, putting all those information together, I figured out how to write a .json file containing the information we need to send the pushes. Here is a sample of the code I used:
{
"MessageRequest": {
"Addresses": {
"YOUR_DEVICE_ADDRESS_HERE": {
"ChannelType": "GCM"
}
},
"MessageConfiguration": {
"GCMMessage": {
"RawContent": "{\"data\":{\"title\":\"StackOverflow rocks!\",\"body\":\"Am I right?\",\"actions\":[ { \"title\":\"Yes!\", \"callback\":\"app.yes\", \"foreground\":true }, { \"title\":\"No!\", \"callback\":\"app.no\", \"foreground\":false }]}}"
}
}
}
}
As you can see, to change the content in the push notificationm, you'll have to edit it's "RawContent". To do so, use the phonegap-plugin tutorial I sent you and find out how to do the alterations you wish.
Last step: once you updated your plugin version AND saved the code above in a .json file (let's call it test.json), you can send it to your phone oppening command line in the folder containing your .json and writting:
aws pinpoint send-messages --color on --region YOUR_SERVICE_REGION --cli-input-json file:///test.json
This should do the trick! Hope it works for you. If any doubts, just let me know!
Getting error "java.lang.NoClassDefFoundError: javax.activation.DataHandler" while Sending automatic email on background..I have added activation.jar ,additional.jar.mail.jar already ,but getting same error again,,plz tell me proper solution..
Thanks in advance..
The Android SDK makes it very easy to send emails from an application, but unfortunately, that's only if you want to send them via the built-in mailing app. For most situations this works fine, but if you want to send something out and don't want any input/intervention from the user, it's not as easy.
so please follow this link
http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_(no_Intents)_in_Android
Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using.
I am new to phonegap and I want to implement pushwoosh notification services but I cant get it right. Every time I call the registerPushwoosh() function I get this error.
I am using the SDK Sample Project -> Android Phonegap.
every time getting this error.
how to fix ["failed to register ","Device does not have package com.google.android.gsf"]
here is image link ERROR AND DIrectory
You need to use Emulator with a Google API.