I've been trying to work with Ionic push notifications and everything went well untill I had to store the Device token which I recieved. I've been following every step the tutorial gave me so I don't see any wrong code in my project.
This is my register code:
// kick off the platform web client
Ionic.io();
var push = new Ionic.Push();
// this will give you a fresh user or the previously saved 'current user'
var user = Ionic.User.current();
// if the user doesn't have an id, you'll need to give it one.
if (!user.id) {
user.id = Ionic.User.anonymousId();
}
var callback = function (data) {
console.log('Registered token:', data.token); // is not empty
console.log(data.token);
push.addTokenToUser(user);
user.save();
}
push.register(callback);
I get the following error:
Ionic Push Token: dev tokens cannot be saved to a user as they are a temporary resource: ionic.io.bundle.min.js (2,5965).
When I'm trying to execute:
push.addTokenToUser(user);
My ionic interface looks this way:
I'm actually expecting my device token to get stored in there. But that isn't the case..
I hope some of you guys have seen this problem before and might be able to help me.
Greetings!
I had this problem until I discovered that I was using an old version of cordova (v.4). Anything below v. 5 does not work properly with Ionic (current Cordova version as of writing is 6.0.0).
npm update -g cordova
Everything worked as documented after that.
Put Ionic in production mode, so it use the certificate you uploaded. (But still in dev mode for devices)
$ ionic push --production-mode=n
Related
Suddenly my code for adding new documents to Firestore is not working and not returning an error. I thought perhaps it was a network issue but Authentication and creating new users is working fine. My network connection is also quite solid.
[EDIT] I've switched on debug mode and a call to Firestore is made with a documentChange request and the correct data fields. The document is never created though. I am on the latest Firestore release.
I tried this simplified add to my collection:
firebase.firestore().collection('biff').add({
boff: 0,
baff: 5
}).catch(function(error) {
console.error('There was an error uploading a file to Cloud Storage:', error);
});
Here are my security rules: (I also tried completely public writing)
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
There are no error messages generated and the new document never appears in my collection. I can authenticate and create new users. Is it possible that authentication is live but somehow my firebase SDK thinks that there is no connection to firestore so its queueing up the documnent writes?
[UPDATE] I noticed that an earlier alpha version of my frontend was still able to write new documents. When I listed the projects firebase knew about in the CLI it listed an older firebase project. So I did 'firebase use --add' and chose my new firebase project and then did a 'firebase init' to reset everything except my index.html. I then did a 'firebase deploy' and lo and behold my deployed version is able to write new documents. My localhost version still is not able to write them though. So very odd. So I am half way there with a solution. All ideas welcome on whats happening on my local machine to stop writes still ...
Once I used a button instead of a form submit to trigger the routine with the document.add then it all worked from localhost, server and mobile. In the broken version the form would continue processing and leave the user in the main view in a state where that url and all urls afterwards had a parameter (?topic=Business) appended to them. From then on the document.add would no longer work. By moving to a button and using e.preventDefault it now works every time and all the urls remain clear. (no idea why this side effect wedged firestore add)
var postOfferElement = document.getElementById('postoffer');
postOfferElement.addEventListener('click', function(e) {
e.preventDefault();
saveOffer();
});
In saveOffer:
firebase.firestore().collection('offers').add({
created: firebase.firestore.FieldValue.serverTimestamp(),
owner: getUserID(),
name: getUserName(),
pic: getProfilePicUrl(),
completes: 0,
favs: 0,
offer: offerText,
topic: topicText,
exp: expText
});
I'm using a Javascript SPA to return a query from Microsoft Graph through the Azure AD application, and it works just fine!
The problem is when I try to loggout from the application, it says I was successfully logged out but if try to log in with another user, it logs into the previous one, in this case, me, without even asking for password.
I needed that this application could log in just few people in my organization, but anyone with "#example.com" can access my application, without the need to be signed to it or not.
I've already cleared the browser's cache and cookies and it doesn't work. Already configured the app to store the cache in the session but it also failed.
The code I'm using is available in:
https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-javascript-spa
The only differences are that I'm using another querys instead the "https://graph.microsoft.com/v1.0/me" and the permissions needed to get them.
I just needed a way to choose specific people to log into the application instead of all the organization and to fix this logout problem.
If I understood you well, I believe your solution is the option select_account.
Here is a code snippet to illustrate:
const clientApplication = new Msal.UserAgentApplication(config);
const loginRequest = {
scopes: [config.webApiScope],
prompt: "select_account",
}
clientApplication.loginPopup(loginRequest).then(function (loginResponse) {
//your code
});
I am using PushSharp library. I am able see deviceToken in the sample code https://github.com/Redth/PushSharp
Can anybody help me how to get that ? PushSharp sample code doesn't explain that
apnsBroker.QueueNotification (new ApnsNotification {
DeviceToken = deviceToken,
Payload = JObject.Parse ("{\"aps\":{\"badge\":7}}")
Same for Android, How can I get the Registration ID's
foreach (var regId in MY_REGISTRATION_IDS) {
// Queue a notification to send
gcmBroker.QueueNotification (new GcmNotification {
RegistrationIds = new List<string> {
regId
},
Data = JObject.Parse ("{ \"somekey\" : \"somevalue\" }")
});
}
I am sending push notification via my service layer which is developed using webapi. Please suggest.
The deviceToken (aka Registration Token) is generated on the client app side.
For GCM - Android, to retrieve the registration token, you'll have to call InstanceID.getToken(). See the official documentation -- Setup a GCM Client on Android:
For GCM - iOS, something similar needs to be done (with further settings needed to connect with APNs). See the official documentation -- Setup a GCM Client on iOS. The guide can be adjusted for Objective-C or Swift.
With that said, the code you referred to is under the section labeled APNS Sample Usage, so I guess it's also safe to refer to this post. Or directly from the Apple Developer site if you plan to directly use APNs without GCM.
PS: If you intend to use GCM, I would strongly recommend that you proceed with using the newer version, which is firebase-cloud-messaging. Official docs here.
I'm making an app using apparchitect and I would like to know how to use JavaScript to call a number. I have tried using different ones already uploaded to no avail. Is it possible to allow a user to (after pushing a button) call a specific number?
In the simplified app maker I can use javascript if they do not have the function I want. This is for an iphone app. Please help this app is really important. Thank you.
The easiest answer for your iPhone app is to include the following HTML (as seen from this answer:
tap to call
Tapping the "tap to call" text on your phone will activate the link and send a message to your app to launch to the provided URL. As long as your app is responding to your webview properly and to the OS, everything should work without JavaScript:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: activatedURLString]]
twilio nodejs library. It's incredibly easy.
1.) Make an account with twilio.
2.) Hook up your button with this code:
// Your accountSid and authToken from twilio.com/user/account go in between quotes
var accountSid = "";
var authToken = "";
var client = require('twilio')(accountSid, authToken); // don't forget to install the twilio libary from npm
client.messages.create({
body: "Jenny please?! I love you <3",
to: "+14159352345",
from: "+14158141829"
}, function(err, message) {
process.stdout.write(message.sid);
});
In fact, I feel like being really nice, so I just uploaded a repository to github which does exactly what you are asking. It uses the Meteor framework. To run it, clone the repo, navigate to the folder in your command line and simple type "meteor" into the command prompt. The site will be running in your browser at localhost3000.
As per the storage api http://developer.chrome.com/extensions/storage.html, I am setting the data like this:
chrome.storage.sync.set({'key': 'value'}, function(){});
Getting value like this:
chrome storage.sync.get(["key1", "key2"], function(res){
});
Locally I tried like this:
Uploaded chrome app to webstore, logged into my gmail, installed app from webstore, open app,
added some data to the app(I mean used app). called the function that uses sync.set. Then cleared localstorage, then called the function that uses sync.get and it worked. But, I tried logging into another system with the same email and installed app and called the function that uses 'sync.get'. This time it returned 'empty' object. Did I miss anything ?
Will provide more information if necessary.
For this case, the answer is that you need to be logged into chrome in both computers, not just the site.