Basically i am taking online course on Udemy. I was copying the same code as as the instructor were typing but got error every time.
I asked the instructor about error. he messaged this to me. But i don't know how to write this in code.
( solution for that. that is you have to pass the apiKey: , appId: , messagingSenderId: , projected: to Firebase.initializeApp(option: FirebaseOption()) parameter then it is working fine. i hope this will help to others. )
can someone please help explain to me that how to do it. or change my code will be a lot easier for me.
thanks in advance.
<script>
const firebaseConfig = {
apiKey: "AIzaSyDuh40Sg-78K6CMC3ByFCubgZE4M2tAcfQ",
authDomain: "tick-it-f1cfe.firebaseapp.com",
projectId: "tick-it-f1cfe",
storageBucket: "tick-it-f1cfe.appspot.com",
messagingSenderId: "300475381561",
appId: "1:300475381561:web:74ae76163157cb07101ae8",
measurementId: "G-BFNKZR1P6S"
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
help me understand this answer to me.
You could try changing const to var because it doesn't really seem right but. What programming language is this and what is it for specifically?
<script>
var firebaseConfig = {
apiKey: "AIzaSyDuh40Sg-78K6CMC3ByFCubgZE4M2tAcfQ",
authDomain: "tick-it-f1cfe.firebaseapp.com",
projectId: "tick-it-f1cfe",
storageBucket: "tick-it-f1cfe.appspot.com",
messagingSenderId: "300475381561",
appId: "1:300475381561:web:74ae76163157cb07101ae8",
measurementId: "G-BFNKZR1P6S"
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
Related
I am trying to add google sign-in feature to my app. This is working fine with an android emulator but I am running the app in the real device it is not working. The problem is after the sign-in process google redirect to its own home page instead to app.
The step I follow.
Function I use to open google sign in page
const result = await Google.logInAsync({
androidStandaloneAppClientId: '131814552849-bi76mebb3eq5jsdergerdfh6werjd8udpen43.apps.googleusercontent.com',
scopes: ['profile', 'email'],
behavior: 'web
});
app.json
I used Google Certificate Hash (SHA-1) in certificateHash
"android": {
"package": "com.abc.mycompnay",
"permissions": ["READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"],
"config": {
"googleSignIn": {
"apiKey": "AIzaSyB6qp9VXGXrtwuihvna40F57xABKXJfEQ",
"certificateHash": "29FD8B159A28F2F48ED3283548NEBFC957F6821D"
}
}
}
google console setting
Client key
After sign in its end up with its own home page
I manage to fix it. below is what I did. I pass the redirectUrl in config
import * as AppAuth from 'expo-app-auth';
const result = await Google.logInAsync({
androidStandaloneAppClientId: 'myKey,
iosStandaloneAppClientId: 'myKey,
scopes: ['profile', 'email'],
behavior: 'web',
redirectUrl: `${AppAuth.OAuthRedirect}:/oauthredirect`
});
Open the gradle and change the redirect scheme
android {
defaultConfig {
manifestPlaceholders = [
appAuthRedirectScheme: 'com.example.yourpackagename'
]
}
}
Okay, I'll put this here since this cost me a ton of lifetime. If you happen to test it with an Android device: Make sure you have selected Chrome as default browser. Others might not redirect you correctly!
In app.json,
package name has to be as all small letters like com.app.cloneapp
In my scenario i need to update firebase database every 1 hour.so i decided to run this in AWS lamda function because of no schedule trigger in cloud function.
Below is my code unable to add firebase library to AWS Lamda function .
'use strict';
import * as admin from 'firebase-admin';
var Firebase = require('firebase');
exports.handler = (event, context, callback) => {
// TODO implement
context.callbackWaitsForEmptyEventLoop = false; //<---Important
var config = {
apiKey: "AIzaSy########################",
authDomain: "########.firebaseapp.com",
databaseURL: "https://a########.firebaseio.com",
projectId: "aws#####",
storageBucket: "",
messagingSenderId: "83526964121"
};
getting below error:
Cannot find module 'firebase'"
"errorMessage": "Unexpected token import",
"errorType": "SyntaxError",
"stackTrace": [
" ^^^^^^",
"SyntaxError: Unexpected token import",
"createScript (vm.js:56:10)",
Cannot find module 'firebase'"
How to add Firebase module to Aws Lamda function.Please give me a hint..
Thanks in advance
if your admin is imported in your lamda function successfully just initialize it with credentials (json file or required fields). See: https://firebase.google.com/docs/admin/setup .
You don't need firebase dependency to do it since lamda function is not visible to users it can use admin access to your database.
Now when your admin sdk is initialize you just need to get the database reference like this (javascript style) :
let db= admin.database();
Now you have reference to the database and you can easily write to the any location since admin has full access to your database.
db.ref().child('/someNode').set({"key":"value"});
Our app allows the user take pictures (and select pictures) from it.
I've used the Expo component ImagePicker for that, as it provides a simple API.
And it works perfectly inside expo (both exp start and exp publish), but it does not work within a standalone apk.
When I try to invoke ImagePicker.launchCameraAsync(), I catch an EUNSPECIFIED exception, but that only in the standalone apk.
Details
An excerpt of the code:
import { ImagePicker } from 'expo';
(...)
const image = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [3, 5],
});
(...)
let image = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [3, 5],
});
It works well within expo, including exp publish version.
As for my permissions in the app.json, what I have is the following:
(...)
"android": {
"package": "br.com.miredefamilia",
"versionCode": 3,
"permissions": [
"android.permissions.CAMERA",
"android.permissions.READ_INTERNAL_STORAGE",
"android.permissions.READ_EXTERNAL_STORAGE"
]
}
I have also tried without the android.permissions.
The mobile does request for the permission, I accept it, and it does not launch the camera / picker, like it does within the expo.
Any help?
This is the proper solution with docs link
Ask for Permission.CAMERA and Permission.CAMERA_ROLL
const { status } = await Permissions.askAsync(Permissions.CAMERA, Permissions.CAMERA_ROLL)
if (status === 'granted') {
ImagePicker.launchCameraAsync({
mediaTypes: 'Images',
allowsEditing: true,
aspect: [1, 1]
})
} else {
// ask user to turn on permission here
}
Also update the app.json with this permissions
CAMERA
READ_EXTERNAL_STORAGE
READ_INTERNAL_STORAGE
Docs link here
Reference
The following changes have fixed the problem:
In the app.json
"android": {
"package": "br.com.miredefamilia",
"versionCode": 3,
"permissions": [
"CAMERA",
"READ_INTERNAL_STORAGE",
"WRITE_INTERNAL_STORAGE",
"READ_EXTERNAL_STORAGE",
"WRITE_EXTERNAL_STORAGE"
]
}
And the calls to the component, I removed the parameters:
const image = await ImagePicker.launchCameraAsync();
let image = await ImagePicker.launchImageLibraryAsync();
I also removed the dependency:
"react-native-camera": "^0.10.0",
I don't know exactly which one solved the problem, but one of them did.
I'm trying to get an ionic App to get the notification badges on launch app icon.
As far as I have seen, it isn't possible if the ionic app is closed (not in background) so, anyone know if it's possible to create an android service that i always running on background and syncing my ionic app, making the update of the icon badge?
Thank you in advance
Since #Shiben asked, this is what I did to solve it.
Install cordova-plugin-firebase
Go to https://firebase.google.com and create your firebase project (see a guide for the configurations)
-In your app.component.ts do something like:
export class MyApp {
rootPage:any = HomePage;
firebase : any;
constructor(public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
private _firebase: Firebase,
public alertCtrl: AlertController) {
platform.ready().then(() => {
(your things)
this.firebase = _firebase;
this.initFirebase();
this.firebase.setBadgeNumber(0);
});
}
And this was my initFirebase():
initFirebase(){
this.firebase.grantPermission();
this.firebase.onTokenRefresh()
.subscribe((token: string) => localStorage.setItem("pushToken", token))
this.firebase.onNotificationOpen()
.subscribe((notification) => {
let alert = this.alertCtrl.create({
title: 'New Notification',
subTitle: "Your notification",
buttons:['OK']
});
alert.present();
});
}
-In yor index.html insert something like this (You got it from firebase)
<script src="https://www.gstatic.com/firebasejs/3.9.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "your key",
authDomain: "your domain",
databaseURL: "your url",
projectId: "your projid",
storageBucket: "your storagebucket",
messagingSenderId: "your messageid"
};
firebase.initializeApp(config);
</script>
I did this a long time ago and something might be change. This can be deprecated or not be the best practices, however, I hope it can get your in the right direction.
I went from using the old parse cloud code to open source parse server on AWS and this part of the main.js does not work.
var Stripe = require('stripe');
Stripe.initialize('sk_live_mylivekey');
var Mailgun = require('mailgun');
Mailgun.initialize("mydomain.mailgun.org");
Native Cloud code modules like Stripe, Mailgun, Sendgrid, Twilio etc. are not available in the open sourced Parse server.
Use official npm modules for the same:
Stripe npm module
Mailgun npm module
Reference: Migrate an existing Parse app - Github
Note:
Because the Parse hosted Cloud Code isn’t running a full node environment, there may be subtle differences in how your Cloud Code runs in Parse Server. We recommend exercising all your critical code paths to ensure full functionality.
I switched from using cloud code for making charges to creating a route in my index.js file for making charges. In index.js create a route as such
var stripe = require('stripe')('sk_test_****');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: false
}));
app.post('/charge', function(req, res){
var token = req.body.token;
var amount = req.body.amount;
stripe.charges.create({
amount: amount,
currency: 'usd',
source: token,
}, function(err, charge){
if(err)
// Error check
else
res.send('Payment successful!');
}
});
I call this route using jQuery post however, you could also call it in a form
var handler = StripeCheckout.configure({
key: 'pk_test_****',
locale: 'auto',
token: function(token){
$.post('/charge', {
token: token.id,
amount: total,
}, function(data, status){
alert(data);
});
}
});