I think it is generally a mistake to have the same data in two separate properties. I don't see why both contactList
and groupedContacts
need to exist. In fact, if contactList
did not exist, you would not have been tempted to try to access it from your template, which will (presumably wrongly) show every single contact under every single letter. The inner loop should be over group.contacts
instead.
Grouping entries in list by first letter
Read Local - Storage syncron/direct
It is not a problem. You must adapt to asynchronous programming.
I have x tasks to execute. How to execute y in parallel until all are finished?
To follow up on that comment, it's almost certain that your data is amenable to preprocessing. Very few natural problems require a thousand distinct independent queries every single time. Instead, there are a handful of choices, and everything else flows from those choices. So if you arranged your database so it had X-many large downloads, even if there was repetition of data in download 1 and download 2, in the long run you'd be saving, because of fewer connections, less likelihood of dropped connection, etc. Redundancy might help you a lot here.
How to best load images from rate-limited host?
InAppBrowser - Return from opened external Link
It doesn't return back to the page from which the external link was
clicked. Instead it returns to some different page of the app and then
navigates to the page from which it was clicked after few seconds.
I have x tasks to execute. How to execute y in parallel until all are finished?
Unfortunately not an option. API design is external and set in stone. I have to make these many requests unfortunately, there is just no other endpoint available. I have to work with what I got
I could add a server side wrapper that does what, but then I have a totally different kind of problem as this app normally doesn't need its own backend at all. So this would add servers, sysadmin, availability to my plate. Not an option.
Best way to implement the whole App wide common Error Handling
What's the best way to implement Error Handling mechanism in Ionic App?
Are there any best practices norms on how to go about it? Like what is the best way to display them in the UI (perhaps an ion-card which is hidden and only displayed in case of error or a toast or maybe our good old alert box), should we also log them somewhere else as well (which obviously will have to cleared/purged), etc.
I am in the final stages of my app development and right now I just log them to console. Should have thought about it at the beginning but being new to Ionic world, wanted to implement the basic functionality first.
Any help/pointers/links/suggestions will be highly appreciated.
Thank you.
I have x tasks to execute. How to execute y in parallel until all are finished?
For now I have this (probably terrible) code that works (in perfect conditions). I realized that I control the resolve/reject of the service methods, so Promise.all
actually could work here:
ids: {};
saveToStorage() {
let details = [];
// save ids to storage
this.storage.set('ids', this.ids).then(ids => {
console.log('storage ids', ids);
// go through ids, return only when all promises inside have resolved
return Promise.all(ids.map(id => {
console.log('id', id);
// get details for id
return this.dataService.getDetails(id).then(_details => {
console.log('getDetails', id, _details);
// save details "out" to variable
details[id] = _details;
});
})).then(result => {
console.log('all resolved: ', details, result);
// save details to storage
this.storage.set('details', details).then(result => {
console.log('storage details', result);
});
});
})
}
(ids
was filled in an earlier function)
This creates a lot of parallel requests, but is fortunately limit by the numbers of http connections per host of the browser/device Poor man's limit
I have x tasks to execute. How to execute y in parallel until all are finished?
I fear performance would be unacceptable even if the API was capable of handling all thousands of these requests concurrently simply due to the limitations of mobile networking, let alone how much more awful things would get if you deliberately started throttling things.
I don't like being a voice of doom, but I am worried that by the time you build this out, you are going to come to the conclusion that it simply won't work as currently designed.
Maybe if you can describe more of the details of what sort of data is being fetched by what criteria, people can suggest ways to improve things. For example, if this were a bulletin board app, instead of having an HTTP request for each post, you change things so a single request gets the next 20 or 50 posts in a thread.
Open app when push notification is clicked
Earlier I implemented push notification using fcm, I send the notification from my server to the mobile which works fine.
The problem
When the push notification arrives on my phone, When I click on it, I expect it to open the application instead it dismisses the notification and that's all.
My Observation
After different test I could notice that once I change the data property from the notification payload from on server from data to notification it works(Once notification is clicked app opens) but the problem with this is that, the app doesn't make sound or vibrate neither thise is show my action button.
This is a snippet of code I used in sending the push notification
var FCM = require('fcm-node');
var fcm = new FCM(serverKey);
var serverKey = require('path-to-server-key.json');
exports.pushNotification = (data) => {
var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)
to: data.push_token,\\\
/**
*notification:{ //This opens the application but doesn't perform other action
*"title":"title"
*};
**/
data: { //Using data works fine but app doesnt open when notification clicked
title: data.name,
body: data.message,
soundname: "default",
"iconColor": "purple",
"image-type": "circle",
image: 'www/assets/icon/icon.png',
summaryText: 'You have a new message',
ledColor: "[0, 0, 255, 0]",
vibrationPattern: "[100, 500]",
"force-start": '1',
actions: '[ { "title": "Reply", "callback": "app.replyMessage", "foreground": "false", "inline": "true" }]'
}
}
fcm.send(message, function (err, response) {
if (err) {
console.log("Something has gone wrong!", err)
} else {
console.log("Successfully sent with response: ", response)
}
})
}
And in my mobileApp I have this
pushNotification() {
//After impoerting the push noification plugin
this.push.hasPermission()
.then((res: any) => {
if (res.isEnabled) {
console.log("Permission granted");
} else {
console.log('No permission for notification');
}
});
const options: PushOptions = {
android: {
senderID: 'my-sender-id',
sound: true,
iconColor:"purple",
vibrate: 'true',
forceShow: 'true'
},
ios: {
alert: 'true',
badge: true,
sound: 'false'
},
windows: {}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) => {
console.log('Received a notification', notification);
});
pushObject.on('registration').subscribe((registration: any) => {
//update user token
console.log(registration.registrationId);
});
pushObject.on('error').subscribe(error => {
console.error('Error with Push plugin', error);
});
}
Kindly assist if you have implemented this before. How can I open the app when push notification is click on
I have x tasks to execute. How to execute y in parallel until all are finished?
The API basically can return a list of IDs, and details for one ID. (Of course the real name sfor things are different, but that really is what it is.) I have to have all details for all IDs in my local database to do things with them depending on the details. So I send some parameters to /ids to get the correct IDs, then /details/:id for each of the returned IDs.
The exepcted number of IDs is between 50 and ~250. One of my testing endpoints has 2000 IDs to really stress the app and connection. I know that the app will suck on non Wifi connections, but that's fine. It also is okay that the "download" process takes some time to finish. I just need a stable way to get this "download" done with enough control over it so I can later handle errors and stuff in non perfect conditions.
InAppBrowser - Return from opened external Link
Specify please. Start page? How is this page special?
Help needed: A "solved" problem with end tags
The problem is in the second-to-last line, which should be </ion-list>
, not <ion-list>
.
I have x tasks to execute. How to execute y in parallel until all are finished?
I still think a caching application server that is capable of serving all details in one request is the best option here.
How to call methods of other java classes while creating plugins for Cordova?
You are creating plugins for Cordova, not Ionic. I changed the post title.
Statusbar backgroundColorByHexString doesn't work
Did you look at the Cordova plugin's Github issues to see if someone else is reporting problems with Android N?
I have x tasks to execute. How to execute y in parallel until all are finished?
Unfortunately not. The additional setup, maintenance and complications (API is rate limited per API, so having all users go through the same one will probably trigger this) forbid this. Just won't work for this project.
Cordova plugin with pwa
Some are, most aren't. Depending on how you build your PWA there is no Cordova at all, so you have to look elsewhere for that functionality.
Ionic v1 with pwa
Oh great, you posted the same question in multiple places. Don't do this.
I answered this here:
Adding Windows platform is trying to add cordova-plugin-wkwebview-engine and causing an error
Hm, maybe update node/npm to a more current version? Same for cordova-android and @ionic/app-scripts.