Hi, Mr. Rohan. can you run onesignal on android? if yes, please tell me how to apply it.
Thanks.
Hi, Mr. Rohan. can you run onesignal on android? if yes, please tell me how to apply it.
Thanks.
Hi, everyone.
Here is my way.
Hi Guang, I could not get it to work yet. It's the same thing. It never returns from window.plugins.OneSignal.startInit. It seems plugin is not being loaded and I'm not sure why. I'm continuing to try to see why. If you find any solution, let me know.
Hi, Mr. Rohan. I don't figure out the way so far. So I will use firebase sdk instead of OneSignal.
Do you know about it?
If yes, please help me.
Regards.
Hello Guang,
Maybe be not so quick to give up? The reason I say so is be because Z has stated that it works. I would reply and state that I have successfully implemented Firebase, However, there is no saying that you will not have issues with Firebase likewise. Possibly you may post discussion in greater details rather than simply stating it don't work? Doing so would help others as well as yourself understand the issues.
best regards
Hi, Jeffry. Thank you for your reply.
I think I have already explained my way how to import OneSignal plugin in appery project.
Could you explain to me how to import firebase plugin in appery projet?
Regards.
Hi Guang,
While I don't have extensive experience with firebase, I do have a working prototype using the web SDK in jqm app. Here is an example to create account and login. In this scenario the following code works. Look at the code and screenshot of the UI and it should be clear. I think that's all there is to it.
code// Initialize Firebase
var config = {
apiKey: "your api key",
authDomain: "your-auth-domain.firebaseapp.com",
databaseURL: "https://xyz.firebaseio.com",
projectId: "xyz",
storageBucket: "",
messagingSenderId: "123"
};
firebase.database.enableLogging(true, true);
var defaultApp = firebase.initializeApp(config);
console.log(defaultApp.name); // "[DEFAULT]"
// You can retrieve services via the defaultApp variable...
var defaultStorage = defaultApp.storage();
var defaultDatabase = defaultApp.database();
console.log(defaultStorage); // "[DEFAULT]"
console.log(defaultDatabase); // "[DEFAULT]"
firebase.database().goOffline();
firebase.database().goOnline();
//var email = "me@gmail.com"
//var password = "pass123"
//createUser(email, password);
function createUser(email, password) {
Code: Select all
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
console.log(error);
});
}
/**
Handles the sign in button press.
*/
function toggleSignIn() {
if (firebase.auth().currentUser) {
// [START signout]
firebase.auth().signOut();
// [END signout]
} else {
var email = document.getElementById('pLogin_email').value;
var password = document.getElementById('pLogin_password').value;
if (email.length < 4) {
alert('Please enter an email address.');
return;
}
if (password.length < 4) {
alert('Please enter a password.');
return;
}
// Sign in with email and pass.
// [START authwithemail]
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(error);
document.getElementById('pLogin_sign_in').disabled = false;
// [END_EXCLUDE]
});
// [END authwithemail]
}
document.getElementById('pLogin_sign_in').disabled = true;
}
/**
Handles the sign up button press.
*/
function handleSignUp() {
var email = document.getElementById('pLogin_email').value;
var password = document.getElementById('pLogin_password').value;
if (email.length < 4) {
alert('Please enter an email address.');
return;
}
if (password.length < 4) {
alert('Please enter a password.');
return;
}
// Sign in with email and pass.
// [START createwithemail]
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
console.log(error);
// [END_EXCLUDE]
});
// [END createwithemail]
}
/**
Sends an email verification to the user.
*/
function sendEmailVerification() {
// [START sendemailverification]
firebase.auth().currentUser.sendEmailVerification().then(function() {
// Email Verification sent!
// [START_EXCLUDE]
alert('Email Verification Sent!');
// [END_EXCLUDE]
});
// [END sendemailverification]
}
function sendPasswordReset() {
var email = document.getElementById('pLogin_email').value;
// [START sendpasswordemail]
firebase.auth().sendPasswordResetEmail(email).then(function() {
// Password Reset Email Sent!
// [START_EXCLUDE]
alert('Password Reset Email Sent!');
// [END_EXCLUDE]
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/invalid-email') {
alert(errorMessage);
} else if (errorCode == 'auth/user-not-found') {
alert(errorMessage);
}
console.log(error);
// [END_EXCLUDE]
});
// [END sendpasswordemail];
}
/**
initApp handles setting up UI event listeners and registering Firebase auth listeners:
- firebase.auth().onAuthStateChanged: This listener is called when the user is signed in or
out, and that is where we update the UI.
*/
function initApp() {
// Listening for auth state changes.
// [START authstatelistener]
firebase.auth().onAuthStateChanged(function(user) {
// [START_EXCLUDE silent]
document.getElementById('pLogin_verify_email').disabled = true;
// [END_EXCLUDE]
if (user) {
// User is signed in.
var displayName = user.displayName;
var email = user.email;
var emailVerified = user.emailVerified;
var photoURL = user.photoURL;
var isAnonymous = user.isAnonymous;
var uid = user.uid;
var providerData = user.providerData;
// [START_EXCLUDE]
document.getElementById('pLogin_sign_in_status').textContent = 'Signed in';
document.getElementById('pLogin_sign_in').textContent = 'Sign out';
document.getElementById('pLogin_account_details').textContent = JSON.stringify(user, null, ' ');
if (!emailVerified) {
document.getElementById('verify_email').disabled = false;
}
// [END_EXCLUDE]
} else {
// User is signed out.
// [START_EXCLUDE]
document.getElementById('pLogin_sign_in_status').textContent = 'Signed out';
document.getElementById('pLogin_sign_in').textContent = 'Sign in';
document.getElementById('pLogin_account_details').textContent = 'null';
// [END_EXCLUDE]
}
// [START_EXCLUDE silent]
document.getElementById('sign_in').disabled = false;
// [END_EXCLUDE]
});
// [END authstatelistener]
document.getElementById('pLogin_sign_in').addEventListener('click', toggleSignIn, false);
document.getElementById('pLogin_sign_up').addEventListener('click', handleSignUp, false);
document.getElementById('pLogin_verify_email').addEventListener('click', sendEmailVerification, false);
document.getElementById('pLogin_password_reset').addEventListener('click', sendPasswordReset, false);
}
// window.onload = function() { initApp();};/code
However, there are probably many ways to do it. of the top of my head you could probably use the android or ios sdk respectively, although this is probably not the best for hybrid cordova app.
you may want to check out the following plugin
https://github.com/arnesson/cordova-p...
https://github.com/fechanique/cordova...
https://github.com/hbmartin/cordova-p...
http://plugins.telerik.com/cordova/pl...
note that I have yet to get any of the telerik cordova plugins to work in appery, not sure why.
hope this helps and good luck
Hi Guang,
Still haven't gotten OneSignal working yet. I am still trying and emailed OneSignal to see if they can look into why it's not working. They think the way Appery is bundling the plugin when exporting is not letting it get loaded. Indeed, when I run a test app I see that OneSignal is never loaded properly. I didn't have a lot of time to work on it, but I am going to keep on trying.
Hi Jeffrey,
Thanks for your sample code. I also got Firebase real-time db working in an Ionic app. That part is not too hard. But I think what Guang is asking (and also my interest in OneSignal) is for the push notifications (i.e. Firebase Cloud messaging).
Did you ever try FCM in your app? If so, let us know what you did.
Guang, I never tried FCM yet, but I would get my client to switch from OneSignal if I could get it to work. Let me know if you make progress with either one. Thanks.
Hi, Mr. Rohan.
I saw config.xml file.
BTW, there is no onesignal plugin. I think it's very important.
for example if i enable firebase plugin, there is.
Make sense?
And how about you?
Please answer me.
Thank you for your time.
Regards.