#NSUserDefaults
Explore tagged Tumblr posts
Text
ios 에서 간단한 정보를 저장
NSKeyedArchiver
NSUserDefaults
를 이용할수 있다.
https://youtu.be/2idtKQ_NqTs?t=1m41s 참조
0 notes
Text
Week 354
Happy Thursday! It’s been a quiet week, mostly. Apple released some marketing tools for app developers, for generating links to the app on the app store, embed code for app icons, download badges, or qr codes. In other news, Alexandre Colucci has analyzed Apple’s use of Swift and SwiftUI in iOS 14 and it’s about twice more than in iOS 13.
Marius Constantinescu
Articles
Mastering ScrollView in SwiftUI, by @mecid
Combine: From zero to… Oh! I get it.(Part I), by @apesate
Label, by @zntfdr
Your iOS Home Screen is a Monoid, Part 1 and Part 2, by @tomasruizlopez
Pitfalls of protocol extensions, by dmtopolog
Snapshot Testing in Swift 📸, by robertofrontado
Setting default values for NSUserDefaults, by @sarunw
Overriding UserDefaults for improved productivity, by @twannl
What does @main do in Swift 5.3?, by @kharrison
Tools/Controls
SwiftUICharts - A simple line and bar charting library that supports accessibility written using SwiftUI, by @mecid
Business/Career
Launching an Indie App - Part 1: Sharing my Journey, by @michael_tigas
Videos
How it’s Built: Scribble Together with Bridger Maxwell, by @zats, with @bridgermax
Credits
mecid, apesate, zntfdr, truizlop, michael_tigas, DmIvanov, robertofrontado, sarunw
1 note
·
View note
Text
Solving Common Cross-Platform Issues When Working With Flutter
When mistreatment cross-platform frameworks, folks may forget the nuances of every of the platforms they need their code to run on. This text aims to handle that.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isn’t that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
Example 1: Storage
I recently wrote on my diary concerning the necessity for a special approach to storing JWTs in net apps compared to mobile apps. That is due to the various nature of the platforms’ storage choices, and therefore the got to recognize every and their native development tools.
WEB
When you write a Web app, the storage options you have are:
1. Downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user.
2. Using cookies, which may or may not be accessible from JS (depending on whether or not they’re httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response.
3. Using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
MOBILE
The situation when it comes to mobile apps is completely different. The storage options are the following:
1. Local app documents or cache storage, accessible by that app.
2. Other local storage paths for user-created/readable files.
3. NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage.
4. Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
If you don’t recognize that, you’re getting to build a multitude of your implementations as a result of you would like to understand what storage answer you’re truly exploitation and what the benefits and downsides area unit.
CROSS-PLATFORM SOLUTIONS: AN INITIAL APPROACH
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android and NSUserDefaults on iOS. Those have utterly completely different implications for your app, particularly if you’re storing sensitive info like session tokens: localStorage are often scan by the shopper, thus it’s a tangle if you’re prone to XSS. although mobile apps aren’t very prone to XSS, SharedPreferences and NSUserDefaults don't seem to be secure storage ways as a result of they will be compromised on the shopper facet since they're not secure storage and not encrypted. That’s as a result of they're meant for user preferences, as mentioned here within the case of iOS and here within the robot documentation once talking concerning the protection library that is meant to produce wrappers to the SharedPreferences specifically to inscribe the info before storing it.
SECURE STORAGE ON MOBILE
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web. The Keychain and KeyStore area unit terribly completely different in nature, though: Keychain could be a generic credentials storage resolution, whereas the KeyStore is employed to store (and will generate) science keys, either stellate keys or public/private keys.
This means that if, for example, you would like to store a session token, on iOS you'll be able to let the OS manage the coding half and simply send your token to the Keychain, whereas on humanoid it’s a small amount a lot of of a manual expertise as a result of you would like to get (not hard-code, that’s bad) a key, use it to cypher the token, store the encrypted token in SharedPreferences and store the key within the KeyStore. There area unit completely different approaches to it, as area unit most things in security, however the only is perhaps to use stellate coding, as there's no want for public key cryptography since your app each encrypts and decrypts the token. Obviously, you don’t have to be compelled to write mobile platform-specific code that will all of that, as there is a Flutter plugin that does all of that, for instance.
THE LACK OF SECURE STORAGE ON THE WEB
That was, actually, the rationale that compelled ME to put in writing this post. I wrote regarding exploitation that package to store JWT on mobile apps and other people wished the net version of that however, as I said, there's no secure storage on the net. It doesn’t exist. Does that mean your JWT must be get in the open? No, not at all. you'll be able to use httpOnly cookies, can’t you? Those area unitn’t accessible by JS and are sent solely to your server. the problem thereupon is that they’re continuously sent to your server, notwithstanding one amongst your users clicks on a GET request address on somebody else’s web site which GET request has aspect effects you or your user won’t like. This really works for different request varieties moreover, it’s simply a lot of sophisticated. It’s referred to as Cross-Site Request Forgery and you don’t wish that. It’s among the net security threats mentioned in Mozilla’s MDN docs, wherever you'll be able to notice a a lot of complete rationalization. There area unit interference strategies. the foremost common one has 2 tokens, actually: one amongst them aiming to the shopper as Associate in Nursing httpOnly cookie, the opposite as a part of the response. The latter must be hold on in localStorage and not in cookies as a result of we have a tendency to don’t wish it to be sent mechanically to the server.
SOLVING BOTH
What if you have both a mobile app and a Web app? That can be dealt with in one of two ways:
1. Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
2. Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, let’s see how we can run different code on different platforms in order to be able to compensate for the differences.
CREATING A FLUTTER PLUGIN
Especially to unravel the matter of storage, a technique you'll do this is with a plugin package: plugins offer a typical Dart interface and might run totally different code on different platforms, together with native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is quite complicated, however it’s explained in several places on the net et al. (for example in Flutter books), together with the official Flutter documentation. For mobile platforms, for example, there already may be a secure storage plugin, and that’s flutter_secure_storage, that you'll notice associate example of usage here, however that doesn’t work on the net, as an example.
On the opposite hand, for easy key-value storage that additionally works on the net, there’s a cross-platform Google-developed first-party plugin package known as shared_preferences, that incorporates a Web-specific part known as shared_preferences_web that uses NSUserDefaults, SharedPreferences or localStorage reckoning on the platform.
TARGETPLATFORM ON FLUTTER
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linux
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
Example 2: Differences In How The Same Widget Is Displayed
You can’t simply write cross-platform code and fake a browser, a phone, a computer, and a smartwatch area unit a similar factor — unless you wish your humanoid and iOS app to be a WebView and your desktop app to be designed with lepton.
There area unit many reasons to not try this, and it’s not the purpose of this piece to convert you to use frameworks like Flutter instead that keep your app native, with all the performance and user expertise blessings that go with it, whereas permitting you to jot down code that's progressing to be a similar for all platforms most of the time.
That requires care and a focus, though, and a minimum of a basic data of the platforms you wish to support, their actual native genus Apis, and every one of that.
React Native users have to be compelled to pay even additional attention thereto as a result of that framework uses the inherent OS widgets, thus you really have to be compelled to pay even additional attention to however the app appearance by testing it extensively on each platforms, while not having the ability to modify between iOS and Material device on the fly like it’s potential with Flutter..
WHAT CHANGES WITHOUT YOUR REQUEST
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Between Android And iOS (Flutter)
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), however what it DOESN’T do is show precisely the same factor on robot and iOS: Material theming particularly adapts to the conventions of every platform.
For instance, navigation animations and transitions and default fonts area unit completely different, however those don’t impact your app that abundant. What might have an effect on a number of your decisions once it involves aesthetics or wife is that the indisputable fact that some static components conjointly modification.
Specifically, some icons modification between the 2 platforms, app bar titles area unit within the middle on iOS and on the left on robot (on the left of the on the market area just in case there's a back button or the button to open a Drawer (explained here within the Material style pointers and conjointly called a hamburger menu). Here’s what a fabric app with a Drawer feels like on Android:
And what the same, very simple, Material app looks like on iOS:
Between Mobile and Web and With Screen Notches (Flutter)
On the online there's a small amount of a unique state of affairs, as mentioned conjointly during this Smashing article regarding Responsive net Development with Flutter: specifically, additionally to having to optimize for larger screens and account for the means folks expect to navigate through your web site — that is that the main focus of that article — you have got to stress regarding the very fact that generally widgets square measure placed outside of the browser window.
Also, some phones have notches within the high a part of their screen or different impediments to the proper viewing of your app attributable to some form of obstruction. Both of those issues may be avoided by wrapping your conveniences during a SafeArea widget, that may be a explicit reasonably cushioning convenience that makes certain your widgets comprise an area wherever they will really be displayed empty preventive the users’ ability to envision them, be it a hardware or code constraint.
IN REACT NATIVE
React Native needs far more attention and a way deeper information of every platform, additionally to requiring you to run the iOS machine furthermore because the mechanical man human at the terribly least so as to be able to check your app on each platforms: it’s not identical and it converts its JavaScript UI parts to platform-specific widgets.
In alternative words, your React Native apps can invariably seem like iOS — with Cupertino UI parts as they're generally known as — and your mechanical man apps can invariably seem like regular Material style mechanical man apps as a result of it’s victimization the platform’s widgets. The distinction here is that Flutter renders its widgets with its own low-level rendering engine, which implies you'll be able to check each app versions on one platform.
Getting Around That Issue
The Other Side: Using The Wrong Widgets For The Right Reasons
But that also means that you can do most of your Flutter development on a Linux or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.It’s great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
We will be happy to answer your questions on designing, developing, and deploying comprehensive enterprise web, mobile apps and customized software solutions that best fit your organization needs. As a reputed Software Solutions Developer we have expertise in providing dedicated remote and outsourced technical resources for software services at very nominal cost. Besides experts in full stacks We also build web solutions, mobile apps and work on system integration, performance enhancement, cloud migrations and big data analytics. Don’t hesitate to
get in touch with us!
0 notes
Text
Solving Common Cross-Platform Issues When Working With Flutter
When mistreatment cross-platform frameworks, folks may forget the nuances of every of the platforms they need their code to run on. This text aims to handle that.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isn’t that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
Example 1: Storage
I recently wrote on my diary concerning the necessity for a special approach to storing JWTs in net apps compared to mobile apps. That is due to the various nature of the platforms’ storage choices, and therefore the got to recognize every and their native development tools.
WEB
When you write a Web app, the storage options you have are:
1. Downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user.
2. Using cookies, which may or may not be accessible from JS (depending on whether or not they’re httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response.
3. Using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
MOBILE
The situation when it comes to mobile apps is completely different. The storage options are the following:
1. Local app documents or cache storage, accessible by that app.
2. Other local storage paths for user-created/readable files.
3. NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage.
4. Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
If you don’t recognize that, you’re getting to build a multitude of your implementations as a result of you would like to understand what storage answer you’re truly exploitation and what the benefits and downsides area unit.
CROSS-PLATFORM SOLUTIONS: AN INITIAL APPROACH
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android and NSUserDefaults on iOS. Those have utterly completely different implications for your app, particularly if you’re storing sensitive info like session tokens: localStorage are often scan by the shopper, thus it’s a tangle if you’re prone to XSS. although mobile apps aren’t very prone to XSS, SharedPreferences and NSUserDefaults don't seem to be secure storage ways as a result of they will be compromised on the shopper facet since they're not secure storage and not encrypted. That’s as a result of they're meant for user preferences, as mentioned here within the case of iOS and here within the robot documentation once talking concerning the protection library that is meant to produce wrappers to the SharedPreferences specifically to inscribe the info before storing it.
SECURE STORAGE ON MOBILE
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web. The Keychain and KeyStore area unit terribly completely different in nature, though: Keychain could be a generic credentials storage resolution, whereas the KeyStore is employed to store (and will generate) science keys, either stellate keys or public/private keys.
This means that if, for example, you would like to store a session token, on iOS you'll be able to let the OS manage the coding half and simply send your token to the Keychain, whereas on humanoid it’s a small amount a lot of of a manual expertise as a result of you would like to get (not hard-code, that’s bad) a key, use it to cypher the token, store the encrypted token in SharedPreferences and store the key within the KeyStore. There area unit completely different approaches to it, as area unit most things in security, however the only is perhaps to use stellate coding, as there's no want for public key cryptography since your app each encrypts and decrypts the token. Obviously, you don’t have to be compelled to write mobile platform-specific code that will all of that, as there is a Flutter plugin that does all of that, for instance.
THE LACK OF SECURE STORAGE ON THE WEB
That was, actually, the rationale that compelled ME to put in writing this post. I wrote regarding exploitation that package to store JWT on mobile apps and other people wished the net version of that however, as I said, there's no secure storage on the net. It doesn’t exist. Does that mean your JWT must be get in the open? No, not at all. you'll be able to use httpOnly cookies, can’t you? Those area unitn’t accessible by JS and are sent solely to your server. the problem thereupon is that they’re continuously sent to your server, notwithstanding one amongst your users clicks on a GET request address on somebody else’s web site which GET request has aspect effects you or your user won’t like. This really works for different request varieties moreover, it’s simply a lot of sophisticated. It’s referred to as Cross-Site Request Forgery and you don’t wish that. It’s among the net security threats mentioned in Mozilla’s MDN docs, wherever you'll be able to notice a a lot of complete rationalization. There area unit interference strategies. the foremost common one has 2 tokens, actually: one amongst them aiming to the shopper as Associate in Nursing httpOnly cookie, the opposite as a part of the response. The latter must be hold on in localStorage and not in cookies as a result of we have a tendency to don’t wish it to be sent mechanically to the server.
SOLVING BOTH
What if you have both a mobile app and a Web app? That can be dealt with in one of two ways:
1. Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
2. Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, let’s see how we can run different code on different platforms in order to be able to compensate for the differences.
CREATING A FLUTTER PLUGIN
Especially to unravel the matter of storage, a technique you'll do this is with a plugin package: plugins offer a typical Dart interface and might run totally different code on different platforms, together with native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is quite complicated, however it’s explained in several places on the net et al. (for example in Flutter books), together with the official Flutter documentation. For mobile platforms, for example, there already may be a secure storage plugin, and that’s flutter_secure_storage, that you'll notice associate example of usage here, however that doesn’t work on the net, as an example.
On the opposite hand, for easy key-value storage that additionally works on the net, there’s a cross-platform Google-developed first-party plugin package known as shared_preferences, that incorporates a Web-specific part known as shared_preferences_web that uses NSUserDefaults, SharedPreferences or localStorage reckoning on the platform.
TARGETPLATFORM ON FLUTTER
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linux
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
Example 2: Differences In How The Same Widget Is Displayed
You can’t simply write cross-platform code and fake a browser, a phone, a computer, and a smartwatch area unit a similar factor — unless you wish your humanoid and iOS app to be a WebView and your desktop app to be designed with lepton.
There area unit many reasons to not try this, and it’s not the purpose of this piece to convert you to use frameworks like Flutter instead that keep your app native, with all the performance and user expertise blessings that go with it, whereas permitting you to jot down code that's progressing to be a similar for all platforms most of the time.
That requires care and a focus, though, and a minimum of a basic data of the platforms you wish to support, their actual native genus Apis, and every one of that.
React Native users have to be compelled to pay even additional attention thereto as a result of that framework uses the inherent OS widgets, thus you really have to be compelled to pay even additional attention to however the app appearance by testing it extensively on each platforms, while not having the ability to modify between iOS and Material device on the fly like it’s potential with Flutter..
WHAT CHANGES WITHOUT YOUR REQUEST
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Between Android And iOS (Flutter)
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), however what it DOESN’T do is show precisely the same factor on robot and iOS: Material theming particularly adapts to the conventions of every platform.
For instance, navigation animations and transitions and default fonts area unit completely different, however those don’t impact your app that abundant. What might have an effect on a number of your decisions once it involves aesthetics or wife is that the indisputable fact that some static components conjointly modification.
Specifically, some icons modification between the 2 platforms, app bar titles area unit within the middle on iOS and on the left on robot (on the left of the on the market area just in case there's a back button or the button to open a Drawer (explained here within the Material style pointers and conjointly called a hamburger menu). Here’s what a fabric app with a Drawer feels like on Android:
And what the same, very simple, Material app looks like on iOS:
Between Mobile and Web and With Screen Notches (Flutter)
On the online there's a small amount of a unique state of affairs, as mentioned conjointly during this Smashing article regarding Responsive net Development with Flutter: specifically, additionally to having to optimize for larger screens and account for the means folks expect to navigate through your web site — that is that the main focus of that article — you have got to stress regarding the very fact that generally widgets square measure placed outside of the browser window.
Also, some phones have notches within the high a part of their screen or different impediments to the proper viewing of your app attributable to some form of obstruction. Both of those issues may be avoided by wrapping your conveniences during a SafeArea widget, that may be a explicit reasonably cushioning convenience that makes certain your widgets comprise an area wherever they will really be displayed empty preventive the users’ ability to envision them, be it a hardware or code constraint.
IN REACT NATIVE
React Native needs far more attention and a way deeper information of every platform, additionally to requiring you to run the iOS machine furthermore because the mechanical man human at the terribly least so as to be able to check your app on each platforms: it’s not identical and it converts its JavaScript UI parts to platform-specific widgets.
In alternative words, your React Native apps can invariably seem like iOS — with Cupertino UI parts as they're generally known as — and your mechanical man apps can invariably seem like regular Material style mechanical man apps as a result of it’s victimization the platform’s widgets. The distinction here is that Flutter renders its widgets with its own low-level rendering engine, which implies you'll be able to check each app versions on one platform.
Getting Around That Issue
The Other Side: Using The Wrong Widgets For The Right Reasons
But that also means that you can do most of your Flutter development on a Linux or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.It’s great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
We will be happy to answer your questions on designing, developing, and deploying comprehensive enterprise web, mobile apps and customized software solutions that best fit your organization needs. As a reputed Software Solutions Developer we have expertise in providing dedicated remote and outsourced technical resources for software services at very nominal cost. Besides experts in full stacks We also build web solutions, mobile apps and work on system integration, performance enhancement, cloud migrations and big data analytics. Don’t hesitate to
get in touch with us!
#b2b ecommerce
#b2bsales
#b2b seo
#b2bservices
#Ecommerce
0 notes
Text
Solving Common Cross-Platform Issues When Working With Flutter
When mistreatment cross-platform frameworks, folks may forget the nuances of every of the platforms they need their code to run on. This text aims to handle that.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isn’t that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
Example 1: Storage
I recently wrote on my diary concerning the necessity for a special approach to storing JWTs in net apps compared to mobile apps. That is due to the various nature of the platforms’ storage choices, and therefore the got to recognize every and their native development tools.
WEB
When you write a Web app, the storage options you have are:
1. Downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user.
2. Using cookies, which may or may not be accessible from JS (depending on whether or not they’re httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response.
3. Using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
MOBILE
The situation when it comes to mobile apps is completely different. The storage options are the following:
1. Local app documents or cache storage, accessible by that app.
2. Other local storage paths for user-created/readable files.
3. NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage.
4. Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
If you don’t recognize that, you’re getting to build a multitude of your implementations as a result of you would like to understand what storage answer you’re truly exploitation and what the benefits and downsides area unit.
CROSS-PLATFORM SOLUTIONS: AN INITIAL APPROACH
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android and NSUserDefaults on iOS. Those have utterly completely different implications for your app, particularly if you’re storing sensitive info like session tokens: localStorage are often scan by the shopper, thus it’s a tangle if you’re prone to XSS. although mobile apps aren’t very prone to XSS, SharedPreferences and NSUserDefaults don't seem to be secure storage ways as a result of they will be compromised on the shopper facet since they're not secure storage and not encrypted. That’s as a result of they're meant for user preferences, as mentioned here within the case of iOS and here within the robot documentation once talking concerning the protection library that is meant to produce wrappers to the SharedPreferences specifically to inscribe the info before storing it.
SECURE STORAGE ON MOBILE
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web. The Keychain and KeyStore area unit terribly completely different in nature, though: Keychain could be a generic credentials storage resolution, whereas the KeyStore is employed to store (and will generate) science keys, either stellate keys or public/private keys.
This means that if, for example, you would like to store a session token, on iOS you'll be able to let the OS manage the coding half and simply send your token to the Keychain, whereas on humanoid it’s a small amount a lot of of a manual expertise as a result of you would like to get (not hard-code, that’s bad) a key, use it to cypher the token, store the encrypted token in SharedPreferences and store the key within the KeyStore. There area unit completely different approaches to it, as area unit most things in security, however the only is perhaps to use stellate coding, as there's no want for public key cryptography since your app each encrypts and decrypts the token. Obviously, you don’t have to be compelled to write mobile platform-specific code that will all of that, as there is a Flutter plugin that does all of that, for instance.
THE LACK OF SECURE STORAGE ON THE WEB
That was, actually, the rationale that compelled ME to put in writing this post. I wrote regarding exploitation that package to store JWT on mobile apps and other people wished the net version of that however, as I said, there's no secure storage on the net. It doesn’t exist. Does that mean your JWT must be get in the open? No, not at all. you'll be able to use httpOnly cookies, can’t you? Those area unitn’t accessible by JS and are sent solely to your server. the problem thereupon is that they’re continuously sent to your server, notwithstanding one amongst your users clicks on a GET request address on somebody else’s web site which GET request has aspect effects you or your user won’t like. This really works for different request varieties moreover, it’s simply a lot of sophisticated. It’s referred to as Cross-Site Request Forgery and you don’t wish that. It’s among the net security threats mentioned in Mozilla’s MDN docs, wherever you'll be able to notice a a lot of complete rationalization. There area unit interference strategies. the foremost common one has 2 tokens, actually: one amongst them aiming to the shopper as Associate in Nursing httpOnly cookie, the opposite as a part of the response. The latter must be hold on in localStorage and not in cookies as a result of we have a tendency to don’t wish it to be sent mechanically to the server.
SOLVING BOTH
What if you have both a mobile app and a Web app? That can be dealt with in one of two ways:
1. Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
2. Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, let’s see how we can run different code on different platforms in order to be able to compensate for the differences.
CREATING A FLUTTER PLUGIN
Especially to unravel the matter of storage, a technique you'll do this is with a plugin package: plugins offer a typical Dart interface and might run totally different code on different platforms, together with native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is quite complicated, however it’s explained in several places on the net et al. (for example in Flutter books), together with the official Flutter documentation. For mobile platforms, for example, there already may be a secure storage plugin, and that’s flutter_secure_storage, that you'll notice associate example of usage here, however that doesn’t work on the net, as an example.
On the opposite hand, for easy key-value storage that additionally works on the net, there’s a cross-platform Google-developed first-party plugin package known as shared_preferences, that incorporates a Web-specific part known as shared_preferences_web that uses NSUserDefaults, SharedPreferences or localStorage reckoning on the platform.
TARGETPLATFORM ON FLUTTER
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linux
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
Example 2: Differences In How The Same Widget Is Displayed
You can’t simply write cross-platform code and fake a browser, a phone, a computer, and a smartwatch area unit a similar factor — unless you wish your humanoid and iOS app to be a WebView and your desktop app to be designed with lepton.
There area unit many reasons to not try this, and it’s not the purpose of this piece to convert you to use frameworks like Flutter instead that keep your app native, with all the performance and user expertise blessings that go with it, whereas permitting you to jot down code that's progressing to be a similar for all platforms most of the time.
That requires care and a focus, though, and a minimum of a basic data of the platforms you wish to support, their actual native genus Apis, and every one of that.
React Native users have to be compelled to pay even additional attention thereto as a result of that framework uses the inherent OS widgets, thus you really have to be compelled to pay even additional attention to however the app appearance by testing it extensively on each platforms, while not having the ability to modify between iOS and Material device on the fly like it’s potential with Flutter..
WHAT CHANGES WITHOUT YOUR REQUEST
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Between Android And iOS (Flutter)
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), however what it DOESN’T do is show precisely the same factor on robot and iOS: Material theming particularly adapts to the conventions of every platform.
For instance, navigation animations and transitions and default fonts area unit completely different, however those don’t impact your app that abundant. What might have an effect on a number of your decisions once it involves aesthetics or wife is that the indisputable fact that some static components conjointly modification.
Specifically, some icons modification between the 2 platforms, app bar titles area unit within the middle on iOS and on the left on robot (on the left of the on the market area just in case there's a back button or the button to open a Drawer (explained here within the Material style pointers and conjointly called a hamburger menu). Here’s what a fabric app with a Drawer feels like on Android:
And what the same, very simple, Material app looks like on iOS:
Between Mobile and Web and With Screen Notches (Flutter)
On the online there's a small amount of a unique state of affairs, as mentioned conjointly during this Smashing article regarding Responsive net Development with Flutter: specifically, additionally to having to optimize for larger screens and account for the means folks expect to navigate through your web site — that is that the main focus of that article — you have got to stress regarding the very fact that generally widgets square measure placed outside of the browser window.
Also, some phones have notches within the high a part of their screen or different impediments to the proper viewing of your app attributable to some form of obstruction. Both of those issues may be avoided by wrapping your conveniences during a SafeArea widget, that may be a explicit reasonably cushioning convenience that makes certain your widgets comprise an area wherever they will really be displayed empty preventive the users’ ability to envision them, be it a hardware or code constraint.
IN REACT NATIVE
React Native needs far more attention and a way deeper information of every platform, additionally to requiring you to run the iOS machine furthermore because the mechanical man human at the terribly least so as to be able to check your app on each platforms: it’s not identical and it converts its JavaScript UI parts to platform-specific widgets.
In alternative words, your React Native apps can invariably seem like iOS — with Cupertino UI parts as they're generally known as — and your mechanical man apps can invariably seem like regular Material style mechanical man apps as a result of it’s victimization the platform’s widgets. The distinction here is that Flutter renders its widgets with its own low-level rendering engine, which implies you'll be able to check each app versions on one platform.
Getting Around That Issue
The Other Side: Using The Wrong Widgets For The Right Reasons
But that also means that you can do most of your Flutter development on a Linux or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.It’s great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
We will be happy to answer your questions on designing, developing, and deploying comprehensive enterprise web, mobile apps and customized software solutions that best fit your organization needs. As a reputed Software Solutions Developer we have expertise in providing dedicated remote and outsourced technical resources for software services at very nominal cost. Besides experts in full stacks We also build web solutions, mobile apps and work on system integration, performance enhancement, cloud migrations and big data analytics. Don’t hesitate to
get in touch with us!
0 notes
Photo
Working with persistent key-value data in your mobile app? Check out the Multiplatform Settings library from @russhwolf. It will help you write persistence logic once in common code, backed by native APIs like SharedPreferences and NSUserDefaults. ➡️ https://t.co/vomby5nSaH https://t.co/KrEwdXE4yK
0 notes
Text
[Flutter] 使用 shared_preferences 套件儲存 APP 資料
[Flutter] 使用 shared_preferences 套件儲存 APP 資料
Flutter logo 前言 開發 APP 的過程中,總難免會有需要將 APP 的資料『儲存』下來的時候,不論是 APP 的參數設定、亦或者是上次使用者最後一次使用的配置 …… 等等。當然,如果我們要開發一個專門用於紀錄的 APP,比方說記帳用的 APP,那麼我們就還是得去設定 SQLite 或是其他資料庫來完成這項工作。 但反過來說,若只是要儲存一些使用者設定或使用者最後一次使用的配置等等,直接開一個 SQLite 似乎大小題大作了點。當然不是說不行,只是我們可以使用更簡單的方式來做到這件事情。 今天我要紀錄的,就是在 Flutter 上十分著名的持久化儲存套件 shared_preferences。這個套件封裝了 Android 平台的 SharedPreferences、iOS 以及 macOS 上的 NSUserDefaults,讓我們我們在 Flutter…
View On WordPress
0 notes
Text
Combating For BigCommerce: The Samurai Approach

youtube
As an eCommerce company owner, the challenge that is biggest you face is making sure that your products or services are competitive in an extremely global marketplace. It is possible to only repeat this if a sound is had by you online marketing strategy set up. SEO could be the mainstay of website marketing right now. The majority of people who buy stuff online rely on search engines like Google, Yahoo and Bing for answers. Should you want to make a sale, you need your eCommerce store to rank on these search engines. Hiring an expert eCommerce SEO service provider is vital with this. SEO may possibly not be the simplest move to make that you can’t understand either by yourself, but it isn’t something. Before looking at third-party Ecommerce Seo Services, it is always simpler to make sure you know very well what you're getting into. Have a look at the basics of SEO, how search engines works, SEO best practices, everything you can get. SEO is about addressing the needs of a consumer. As long them what they need, you will do well as you offer. Try and understand the mindset of your customers and exactly how their online buying behavior has to be catered to. Because they build this understanding, you give yourself a better chance of getting the maximum from your SEO team. Budget and email address details are your two biggest considerations. You might hire a full-time SEO expert as a member of staff, but that might be too costly. Hiring a digital marketing company to offer you with eCommerce SEO services, on the other hand, provides you with results without becoming a burden in your pocket. The trick would be to finding one with a proven track record of providing results. Also, that it is achievable. 1 for your keyword on Google might be the dream of every entrepreneur, but you are competing against thousands for one spot although it’s good to have a target in mind, make sure. An improved target to aim for could be more traffic and conversions. Once you understand what you need, it will be easier for you to find a person who can satisfy your desires. You'll find so many marketing agencies out there eCommerce that is offering services. Most of them shall speak about quick results. But when they are doing, this would be a red flag for you. The fact about SEO is that there was a great way to do things and a way that is bad. The bad way consist of shortcuts or black hat techniques, which will enable you to get in big trouble into the run that is long. Search engines may penalize your internet site and once that happens, you may never recover. It’s vital with its expertise and experience that it knows what it is doing that you go for an agency that can convince you. Your SEO service provider should take the time for you to help keep you informed about each aspect of their online strategy. In place of hoping to meet up targets that are unrealistic their aim should be to give you an acceptable ROI. When dealing with reliable eCommerce SEO services, 1 Digital Agency is up there using the best. The intricacies are understood by us of internet marketing. We understand what buyers that are online hunting for. Our SEO strategies are made to give your business the boost it needs while keep every step was informed by you associated with way.
BigCommerce
Such accelerated processors may further include instruction set(s) for acceleration using coprocessors and/or other logic to facilitate such acceleration. Computer system 500 could also include a main or memory that is primary, such as for instance random access memory (RAM). Main memory 508 may include a number of quantities of cache. Main memory 508 may have stored therein control logic (i.e., computer programs) and/or data. Computer system 500 might also include more than one storage that is secondary or secondary memory 510. Secondary memory 510 may include, as an example, a main storage drive 512 and/or a removable storage device or drive 514. Main storage drive 512 may be a disk that is hard or solid-state drive, for instance. Removable storage drive 514 may be a disk that is floppy, a magnetic tape drive, a concise disk drive, an optical storage device, tape backup device, and/or any other storage device/drive. Removable storage unit 518 can sometimes include a computer usable or storage that is readable having stored thereon software applications (control logic) and/or data. Removable storage unit 518 can be a disk that is floppy magnetic tape, compact disk, DVD, optical storage disk, and/any other computer data storage device. Secondary memory 510 may include other means, devices, components, instrumentalities or other approaches for allowing computer programs and/or other instructions and/or data to be accessed by computer system 500. Such means, devices, components, instrumentalities or other approaches can sometimes include, for instance, a removable storage unit 522 and an interface 520. Samples of the storage that is removable 522 together with interface 520 may include a course cartridge and cartridge interface (such as that found in video game devices), a removable memory chip (such as for example an EPROM or PROM) and associated socket, a memory stick and USB port, a memory card and associated memory card slot, and/or every other removable storage unit and associated interface. Computer system 500 may also be any of an individual assistant that is digitalPDA), desktop workstation, laptop or portable computers, netbook, tablet, cell phone, smart watch or other wearable, appliance, part of the Internet of Things (IoT), and/or embedded system, to name a few non-limiting examples, or any combination thereof.
Leading POS systems like Shopkeep
New Relic
P/E Ratio n/a
2 Information and reviews
Unlimited staff accounts
PCI DSS certified platform that is e-commerce encrypted checkout
Computer system 500 can be a client or server, accessing or hosting any applications and/or data through any delivery paradigm, including not restricted to remote or distributed cloud computing solutions, local or software that is on-premisese.g., "on-premise" cloud-based solutions); "as a service" models (e.g., content as a service (CaaS), digital content as a service (DCaaS), software as a service (SaaS), managed software as a service (MSaaS), platform as a service (PaaS), desktop as a site (DaaS), framework as a site (FaaS), backend as a site (BaaS), mobile backend as a site (MBaaS), infrastructure as a service (IaaS), database as a site (DBaaS), etc.); and/or a hybrid model including any mix of the foregoing examples or other services or delivery paradigms. Any applicable data structures, file formats, and schemas may be produced by standards including but not restricted to JavaScript Object Notation (JSON), Extensible Markup Language (XML), Yet Another Markup Language (YAML), Extensible Hypertext Markup Language (XHTML), Wireless Markup Language (WML), MessagePack, XML User Interface Language (XUL), or any other functionally similar representations alone or in combination. Alternatively, proprietary data structures, formats or schemas can be used, either exclusively or in combination with known or standards that are open. Any pertinent data, files, and/or databases may be stored, retrieved, accessed, and/or transmitted in human-readable formats such as for instance numeric, textual, graphic, or multimedia formats, further including various types of markup language, among other possible formats. Alternatively or in combination with the aforementioned formats, the information, files, and/or databases could be stored, retrieved, accessed, and/or transmitted in binary, encoded, compressed, and/or encrypted formats, or just about any machine-readable formats. Interfacing or interconnection among various systems and layers may employ any number of mechanisms, such as for instance any number of protocols, programmatic frameworks, floorplans, or application programming interfaces (API), including but not limited to Document Object Model (DOM), Discovery Service (DS), NSUserDefaults, Web Services Description Language (WSDL), Message Exchange Pattern (MEP), Web Distributed Data Exchange (WDDX), Web Hypertext Application Technology Working Group (WHATWG) HTML5 Web Messaging, Representational State Transfer (REST or web that is RESTful), Extensible User Interface Protocol (XUP), Simple Object Access Protocol (SOAP), XML Schema Definition (XSD), XML Remote Procedure Call (XML-RPC), or every other mechanisms, open or proprietary, that will achieve similar functionality and results. Such interfacing or interconnection might also take advantage of uniform resource identifiers (URI), which might further include uniform resource locators (URL) or uniform resource names (URN). Other designs of uniform and/or unique identifiers, locators, or names works extremely well, either exclusively or in conjunction with forms such as those set forth above. Some of the above protocols or APIs may interface with or be implemented in just about any programming language, procedural, functional, or object-oriented, and might be compiled or interpreted.
BigCommerce Is Bound To Make An Impact In Your Business
Objective-C, Java, Swift, Go, Ruby, Perl, Python, JavaScript, WebAssembly, or almost any other language, with any other libraries or schemas, in every types of framework, runtime environment, virtual machine, interpreter, stack, engine, or similar mechanism, including not limited by Node.js, VS, Knockout, jQuery, Dojo, Dijit, OpenUI5, AngularJS, Express.js, Backbone.js, Ember.js, DHTMLX, Vue, React, Electron, and so on, among many other non-limiting examples. Chaincode or contract that is smart may be encoded or programmed using at the very least some of the above programming languages and/or frameworks, e.g., Node.js with JavaScript, other general-purpose programming languages such as for example Go, and/or domain-specific languages such as for example Solidity, to name a couple of non-limiting examples. Any additional libraries, shim code, middleware, APIs, or other logic might be introduced in order to make smart instruments reliably executable (or self-executable) on any given target platform(s) for development, testing, staging, and/or deployment to production, based on some embodiments. In a few embodiments, a tangible, non-transitory apparatus or article of manufacture comprising a tangible, non-transitory computer useable or readable medium having control logic (software) stored thereon may also be referred to herein as some type of computer program product or program storage device. This consists of, but is not limited to, computer system 500, main memory 508, secondary memory 510, and removable storage units 518 and 522, along with tangible articles of manufacture embodying any combination of the foregoing. Such control logic, when executed by a number of data processing devices (such as for instance computer system 500), might cause such data processing devices to operate as described herein. On the basis of the teachings contained in this disclosure, it'll be apparent to persons skilled into the art( that is relevant) steps to make and make use of embodiments with this disclosure using data processing devices, computer systems and/or computer architectures besides that shown in FIG. 5. In particular, embodiments may operate with software, hardware, and/or operating system implementations other than those described herein. It is to be appreciated that the Detailed Description section, and not just about any section, will be used to interpret the claims. Other sections may set forth a number of yet not all exemplary embodiments as contemplated by the inventor(s), and therefore, are not meant to limit this disclosure or the appended claims in any way. While this disclosure describes exemplary embodiments for exemplary fields and applications, it should be understood that the disclosure just isn't limited thereto. Other embodiments and modifications thereto are possible, and therefore are within the spirit and scope with this disclosure. For example, and without limiting the generality of the paragraph, embodiments are not restricted to the software, hardware, firmware, and/or entities illustrated in the figures and/or described herein. Further, embodiments (whether or not explicitly described herein) have significant utility to fields and applications beyond the examples described herein. Embodiments have already been described herein aided by the aid of functional building blocks illustrating the utilization of specified functions and relationships thereof. The boundaries among these functional building blocks have been arbitrarily defined herein for the capability of the description. Alternate boundaries may long be defined as as the specified functions and relationships (or equivalents thereof) are appropriately performed. Also, alternative embodiments may perform functional blocks, steps, operations, methods, etc. using orderings distinctive from those described herein. References herein to "one embodiment," "an embodiment," "an example embodiment," "some embodiments," or similar phrases, indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may not necessarily are the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily talking about the same embodiment. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it will be inside the knowledge of persons skilled within the relevant art(s) to add such feature, structure, or characteristic into other embodiments whether or not explicitly mentioned or described herein. Additionally, some embodiments could be described utilising the expression "coupled"connected and"" along with their derivatives. These terms are not necessarily intended as synonyms for each other. As an example, some embodiments might be described using the terms "connected" and/or "coupled" to indicate that two or more elements have been in direct physical or contact that is electrical each other. The word "coupled," however, may also mean that two or more elements are not in direct connection with each other, and yet still interact or co-operate with every other.
For more information on BigCommerce take a look at our own website.
0 notes
Photo
Just Pinned to Flutter: Shared preferences flutter is for Storing simple data on Device for Reading & writing Simple Key-value pairs in iOS & Android. Shared preferences in flutter NSUserDefaults on iOS & macOS, and SharedPreferences on Android. 💻Shared Preferences:- https://ift.tt/33YXzGy 👩💻Github Code: https://ift.tt/3m78C7n https://ift.tt/32mgH04
0 notes
Photo
Apptober: Days 24/25
Woot, I think I’m happy enough with where the RightMeow app is at that I can call it mostly complete! It’s still a little rough around the edges, but it does what I want it do: namely, allowing me to put a reminder on my watch face of the thing I’m supposed to be doing but got distracted from (because damnit ADHD). I particularly like using it for projects that make me fetch things from across the house (like cleaning or packing), but it’s nice to be able to put anything there, too. Sometimes I just like my watch to tell me that I’m awesome or to remind me to appreciate my surroundings.
A Recap on the Fun Things I learned/implemented doing RightMeow:
learned how to build a native WatchKit app that allows users to input a task they don't want to forget right on their watch via dictation (or scribbles!)
built a complication to put the task on the watch face (this is my fav feature by far)
Implemented the Siri Intents extension to give (VERY limited) support for Siri set the status (most disappointing feature TBH - Siri understands me inconsistently at best and not at all at worst)
Used AppGroups to share data between the phone app and its Siri extension (super easy to implement if you’re using NSUserDefaults to store data)
Used WatchConnectivity to sync the status between watch and phone apps (this was especially fun to do)
Things I might still get around to:
The phone app could use a face-lift
Any work at all on the icon or art assets
Maybe I'll list it in the App Store, just in time to be a month late honoring ADHD awareness month 😂
Up Next:
While I've still got some things left to do with RightMeow, most of them are kinda boring and I've been thinking about devoting the remaining days of Apptober to something new and shiny.
I've been thinking I might build a basic AO3 reader app or something since I've had to take a lot of trips lately and it makes me fantasize about reading Dishonored fanfics in style (and also damnit Safari do you have to try to refresh tabs I've already loaded when you KNOW I don't have wifi access?!?!).
There are probably a billion of them already out there, but hey, it sounds fun and I subscribe to the two cakes theory of content production. What do you guys think?
#apptober#programming#coding#indiedev#app development#software delelopment#software dev#productivity#watchkit#ios#ios development#apple watch development#adhd#swift development#swift programming#ao3#ao3 reader
17 notes
·
View notes
Text
Week 277
Happy Thursday, everyone! I've read a lot this week about the first image of a black hole. I've watched the TED talk given by Dr. Katie Bouman (yes, she has a PhD, so she's a doctor, despite most of the media calling her "the student who made the algorithm") two years ago, and it's amazing we got to see now the results of the study. This huge achievement gave me food for thought. There's a big group of scientists from many different disciplines who worked for many years to get to this result, which also confirms Einstein's theory of relativity from a hundred years ago. They got data from a galaxy 55 million light-years away from us, using telescopes from around the world, and processed all that data to get the first image of a black hole. What did I do this week? Localized an app, code reviewed a networking layer and implemented phone authentication with Firebase 😕. I'm not saying I don't like what I do. But it makes me wonder if I could be doing more, if my work could be a bit more meaningful, if it could help more people or create more value for the humanity. I think this is a good question to ask ourselves, from time to time.
Articles
Open app in specific view when push notification is tapped, by @soulchildpls
Using unwind segues to navigate back to previous screens, by @appsdissected
Stubbing in pair with Swift compiler: a spy registration, by @norapsi
Swift 5 Frozen enums, by @kharrison
Inclusive enums with OptionSet, by @mecid
Conditional Compilation, Part 3: App Extensions, by @davedelong
Building a dynamic modular iOS architecture, by @JareckiMark
Tools/Controls
SecureDefaults - A lightweight wrapper over UserDefaults/NSUserDefaults with an extra AES-256 encryption layer, by @vpeschenkov
optionals.org - A website that shows many various ways to use optionals in Swift, by Caleb
Codextended - Extensions giving Swift's Codable API type inference super powers, by @johnsundell
nef - A command line tool to compile Swift documentation written in Playground format with Bow support, by @47deg
Business/Career
Working together when we’re not together, by Veronica Gilrane
Programming: doing it more vs doing it better, by @lonesword_
UI/UX
Updated Human Interface Guidelines - Accessibility, by Apple
Create App Store Videos With Trailer App, by @dagostin
Videos
How to Kickstart Your Software Engineering Career, by @hellomayuko
Credits
naeemshaikh90, LisaDziuba, Apps Dissected, vpeschenkov, polac24, popei69, mecid, samdods, mikina, rbarbosa
2 notes
·
View notes
Text
July 14, 2020 at 10:00PM - The Complete Game Design & Developer Bundle (95% discount) Ashraf
The Complete Game Design & Developer Bundle (95% discount) Hurry Offer Only Last For HoursSometime. Don't ever forget to share this post on Your Social media to be the first to tell your firends. This is not a fake stuff its real.
Description
Certainly you can spend endless hours pouring over the minutiae of game development theory, but the only way to really learn is by doing. Throughout this course, you’ll walk through the process of building 5 games for various Apple devices, master use of SpriteKit in Swift, and finish your lessons having built real apps you can proudly publish for immediate usage.
Learn to code by building games w/ 5 hours of content
Create 5 games for iPad, iPhone & OS X
Master using Swift & SpriteKit for iOS 9
Make simple art for your game in Photoshop & Illustrator
Configure the logic of your games
Export your apps & publish them to the iTunes Store
Build skills transferrable to future endeavors
Description
Why waste thousands of dollars on a formal video game development degree? Avoid a lifetime of loan payments, and get practical experience you can instantly use to develop your own games. In this comprehensive course, you’ll learn everything you need to create the next iTunes Store chart-topper: how to animate characters, model 2D and 3D images, and much more.
Create premium video game art w/ 87 hours of content
Access a wide array of game design topics: basic traditional drawing, training to be a professional video game artist, etc.
Learn the basics of 3ds Max & use it to create real-life projects
Understand 2D & 3D drawing techniques
Fully master game layout & design principles
Get a primer on video game art, animation, 2D & 3D modeling, layout, and design
Description
Master game app creation by utilizing JavaScript in conjunction with the Phaser HTML5 development framework. With Phaser’s cross-platform features, you’ll gain an understanding of a hybrid app development process that will turn you into a flexible, versatile game developer, able to craft apps for both iOS and Android alike.
Create 5 mobile games using JavaScript & the Phaser library w/ 10 hours of content
Understand the hybrid app development process
Configure home & loading screens, on-screen controls, etc.
Jazz up your games w/ sound, text, animations & more
Publish to the iOS & Android platforms w/ the Intel XDK
Become proficient in JavaScript & HTML5 development
Description
The best way to create an iTunes chart-topper is by emulating one. In this course, you’ll be cloning the popular game, Crossy Road as you learn the best game development practices to create your own hit. Dive into obtaining your iOS developer license, create a game in Unity3D with minimal code, then use your newfound skills towards any future game development projects.
Use Unity3D to create games w/ 6.5 hours of content
Get your iOS developer license
Create a game for iOS or Android using minimal code
Program animations, build a game menu & keep score
Import artwork into Unity3D & utilize it in the games you develop
Learn how to publish games to the iTunes App Store
Description
The demand for 3D modeling and animation skills is growing across a number of industries, from gaming to architecture, and there has never been a better time to delve into this exciting and lucrative field. In this course you’ll use Blender 3D, a feature-rich, free modeling and animation suite to bring 3D creations to life. The creative possibilities in Blender 3D are nearly limitless, as you’ll soon find out!
Access 45 lectures & 6 hours of content 24/7
Model your own 3D meshes using a variety of modeling techniques & workflows
UV map objects using projection & unwrapping
Texture 3D models & work w/ materials
Configure scene lighting & use Blender’s animation tools to animate objects & scenes
Work w/ ambient, atmospheric rendering effects
Perform basic simulations using the built-in game engine
Description
Gaming in the Apple universe now extends to tvOS, and allows developers to leverage many of the same frameworks, technologies, and concepts of iOS development to build games for Apple TV. Whether you’re an experienced iOS programmer or brand new, this course will introduce you to core game development concepts while you build real games for both iOS and tvOS.
Learn to build games for tvOS & iOS w/ 40 lectures & 10 hours of content
Create a tvOS template for navigating between game scenes, passing data around classes & saving data using NSUserDefaults
Build a retro 2d-style side scroller game from scratch for tvOS or iOS
Share code & assets between a tvOS template & an iOS template
Design physics-based environments & program simple, interactive characters
Incorporate a property list to change variables on a per-level basis
Discuss scoring, moving platforms, continue points, inventory & much more
from Active Sales – SharewareOnSale https://ift.tt/32jfl6D https://ift.tt/eA8V8J via Blogger https://ift.tt/2ZuEQ3d #blogger #bloggingtips #bloggerlife #bloggersgetsocial #ontheblog #writersofinstagram #writingprompt #instapoetry #writerscommunity #writersofig #writersblock #writerlife #writtenword #instawriters #spilledink #wordgasm #creativewriting #poetsofinstagram #blackoutpoetry #poetsofig
0 notes
Text
Solving Common Cross-Platform Issues When Working With Flutter
About The Author
Flutter and LinUX enthusiast, author of the Programming Flutter book with the Pragmatic Bookshelf. Blogs more, tweets less. More about Carmine …
When using cross-platform frameworks, people might forget the nuances of each of the platforms they want their code to run on. This article aims to address that.
I’ve seen a lot of confusion online regarding Web development with Flutter and, often, it’s sadly for the wrong reasons.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isn’t that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
In this article, we’re going to see some of those differences and how to overcome them. More specifically, we’re going to talk about storage and UI differences, which are the ones that most often cause confusion to developers when writing Flutter code that they want to be cross-platform.
Example 1: Storage
I recently wrote on my blog about the need for a different approach to storing JWTs in Web apps when compared to mobile apps.
That is because of the different nature of the platforms’ storage options, and the need to know each and their native development tools.
Web
When you write a Web app, the storage options you have are:
downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user;
using cookies, which may or may not be accessible from JS (depending on whether or not they’re httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response;
using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
Mobile
The situation when it comes to mobile apps is completely different. The storage options are the following:
local app documents or cache storage, accessible by that app;
other local storage paths for user-created/readable files;
NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage;
Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
If you don’t know that, you’re going to make a mess of your implementations because you need to know what storage solution you’re actually using and what the advantages and drawbacks are.
Cross-Platform Solutions: An Initial Approach
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android and NSUserDefaults on iOS. Those have completely different implications for your app, especially if you’re storing sensitive information like session tokens: localStorage can be read by the client, so it’s a problem if you’re vulnerable to XSS. Even though mobile apps aren’t really vulnerable to XSS, SharedPreferences and NSUserDefaults are not secure storage methods because they can be compromised on the client side since they are not secure storage and not encrypted. That’s because they are meant for user preferences, as mentioned here in the case of iOS and here in the Android documentation when talking about the Security library which is designed to provide wrappers to the SharedPreferences specifically to encrypt the data before storing it.
Secure Storage On Mobile
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web.
The Keychain and KeyStore are very different in nature, though: Keychain is a generic credentials storage solution, whereas the KeyStore is used to store (and can generate) cryptographic keys, either symmetric keys or public/private keys.
This means that if, for instance, you need to store a session token, on iOS you can let the OS manage the encryption part and just send your token to the Keychain, whereas on Android it’s a bit more of a manual experience because you need to generate (not hard-code, that’s bad) a key, use it to encrypt the token, store the encrypted token in SharedPreferences and store the key in the KeyStore.
There are different approaches to that, as are most things in security, but the simplest is probably to use symmetric encryption, as there is no need for public key cryptography since your app both encrypts and decrypts the token.
Obviously, you don’t need to write mobile platform-specific code that does all of that, as there is a Flutter plugin that does all of that, for instance.
The Lack Of Secure Storage On the Web
That was, actually, the reason that compelled me to write this post. I wrote about using that package to store JWT on mobile apps and people wanted the Web version of that but, as I said, there is no secure storage on the Web. It doesn’t exist.
Does that mean your JWT has to be out in the open?
No, not at all. You can use httpOnly cookies, can’t you? Those aren’t accessible by JS and are sent only to your server. The issue with that is that they’re always sent to your server, even if one of your users clicks on a GET request URL on someone else’s website and that GET request has side effects you or your user won’t like. This actually works for other request types as well, it’s just more complicated. It’s called Cross-Site Request Forgery and you don’t want that. It’s among the web security threats mentioned in Mozilla’s MDN docs, where you can find a more complete explanation.
There are prevention methods. The most common one is having two tokens, actually: one of them getting to the client as an httpOnly cookie, the other as part of the response. The latter has to be stored in localStorage and not in cookies because we don’t want it to be sent automatically to the server.
Solving Both
What if you have both a mobile app and a Web app?
That can be dealt with in one of two ways:
Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, let’s see how we can run different code on different platforms in order to be able to compensate for the differences.
Creating A Flutter Plugin
Especially to solve the problem of storage, one way you can do that is with a plugin package: plugins provide a common Dart interface and can run different code on different platforms, including native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is rather complex, but it’s explained in many places on the Web and elsewhere (for example in Flutter books), including the official Flutter documentation.
For mobile platforms, for instance, there already is a secure storage plugin, and that’s flutter_secure_storage, for which you can find an example of usage here, but that doesn’t work on the Web, for example.
On the other hand, for simple key-value storage that also works on the web, there’s a cross-platform Google-developed first-party plugin package called shared_preferences, which has a Web-specific component called shared_preferences_web which uses NSUserDefaults, SharedPreferences or localStorage depending on the platform.
TargetPlatform on Flutter
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linUX
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
Example 2: Differences In How The Same Widget Is Displayed
You can’t just write cross-platform code and pretend a browser, a phone, a computer, and a smartwatch are the same thing — unless you want your Android and iOS app to be a WebView and your desktop app to be built with Electron. There are plenty of reasons not to do that, and it’s not the point of this piece to convince you to use frameworks like Flutter instead that keep your app native, with all the performance and user experience advantages that come with it, while allowing you to write code that is going to be the same for all platforms most of the time.
That requires care and attention, though, and at least a basic knowledge of the platforms you want to support, their actual native APIs, and all of that. React Native users need to pay even more attention to that because that framework uses the built-in OS widgets, so you actually need to pay even more attention to how the app looks by testing it extensively on both platforms, without being able to switch between iOS and Material widget on the fly like it’s possible with Flutter.
What Changes Without Your Request
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Between Android And iOS (Flutter)
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), but what it DOESN’T do is show exactly the same thing on Android and iOS: Material theming especially adapts to the conventions of each platform.
For instance, navigation animations and transitions and default fonts are different, but those don’t impact your app that much.
What may affect some of your choices when it comes to aesthetics or UX is the fact that some static elements also change. Specifically, some icons change between the two platforms, app bar titles are in the middle on iOS and on the left on Android (on the left of the available space in case there is a back button or the button to open a Drawer (explained here in the Material Design guidelines and also known as a hamburger menu). Here’s what a Material app with a Drawer looks like on Android:
Material app running on Android: the AppBar title is in the left side of the available space. (Large preview)
And what the same, very simple, Material app looks like on iOS:
Material app running on iOS: the AppBar title is in the middle. (Large preview)
Between Mobile and Web and With Screen Notches (Flutter)
On the Web there is a bit of a different situation, as mentioned also in this Smashing article about Responsive Web Development with Flutter: in particular, in addition to having to optimize for bigger screens and account for the way people expect to navigate through your site — which is the main focus of that article — you have to worry about the fact that sometimes widgets are placed outside of the browser window. Also, some phones have notches in the top part of their screen or other impediments to the correct viewing of your app because of some sort of obstruction.
Both of these problems can be avoided by wrapping your widgets in a SafeArea widget, which is a particular kind of padding widget which makes sure your widgets fall into a place where they can actually be displayed without anything impeding the users’ ability to see them, be it a hardware or software constraint.
In React Native
React Native requires much more attention and a much deeper knowledge of each platform, in addition to requiring you to run the iOS Simulator as well as the Android Emulator at the very least in order to be able to test your app on both platforms: it’s not the same and it converts its JavaScript UI elements to platform-specific widgets. In other words, your React Native apps will always look like iOS — with Cupertino UI elements as they are sometimes called — and your Android apps will always look like regular Material Design Android apps because it’s using the platform’s widgets.
The difference here is that Flutter renders its widgets with its own low-level rendering engine, which means you can test both app versions on one platform.
Getting Around That Issue
Unless you’re going for something very specific, your app is supposed to look different on different platforms otherwise some of your users will be unhappy.
Just like you shouldn’t simply ship a mobile app to the web (as I wrote in the aforementioned Smashing post), you shouldn’t ship an app full of Cupertino widgets to Android users, for example, because it’s going to be confusing for the most part. On the other hand, having the chance to actually run an app that has widgets that are meant for another platform allows you to test the app and show it to people in both versions without having to use two devices for that necessarily.
The Other Side: Using The Wrong Widgets For The Right Reasons
But that also means that you can do most of your Flutter development on a LinUX or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps
Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.
It’s great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
Further Resources
(ra, yk, il)
Website Design & SEO Delray Beach by DBL07.co
Delray Beach SEO
source http://www.scpie.org/solving-common-cross-platform-issues-when-working-with-flutter/ source https://scpie1.blogspot.com/2020/06/solving-common-cross-platform-issues.html
0 notes
Text
Solving Common Cross-Platform Issues When Working With Flutter
About The Author
Flutter and LinUX enthusiast, author of the Programming Flutter book with the Pragmatic Bookshelf. Blogs more, tweets less. More about Carmine …
When using cross-platform frameworks, people might forget the nuances of each of the platforms they want their code to run on. This article aims to address that.
I’ve seen a lot of confusion online regarding Web development with Flutter and, often, it’s sadly for the wrong reasons.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isn’t that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
In this article, we’re going to see some of those differences and how to overcome them. More specifically, we’re going to talk about storage and UI differences, which are the ones that most often cause confusion to developers when writing Flutter code that they want to be cross-platform.
Example 1: Storage
I recently wrote on my blog about the need for a different approach to storing JWTs in Web apps when compared to mobile apps.
That is because of the different nature of the platforms’ storage options, and the need to know each and their native development tools.
Web
When you write a Web app, the storage options you have are:
downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user;
using cookies, which may or may not be accessible from JS (depending on whether or not they’re httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response;
using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
Mobile
The situation when it comes to mobile apps is completely different. The storage options are the following:
local app documents or cache storage, accessible by that app;
other local storage paths for user-created/readable files;
NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage;
Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
If you don’t know that, you’re going to make a mess of your implementations because you need to know what storage solution you’re actually using and what the advantages and drawbacks are.
Cross-Platform Solutions: An Initial Approach
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android and NSUserDefaults on iOS. Those have completely different implications for your app, especially if you’re storing sensitive information like session tokens: localStorage can be read by the client, so it’s a problem if you’re vulnerable to XSS. Even though mobile apps aren’t really vulnerable to XSS, SharedPreferences and NSUserDefaults are not secure storage methods because they can be compromised on the client side since they are not secure storage and not encrypted. That’s because they are meant for user preferences, as mentioned here in the case of iOS and here in the Android documentation when talking about the Security library which is designed to provide wrappers to the SharedPreferences specifically to encrypt the data before storing it.
Secure Storage On Mobile
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web.
The Keychain and KeyStore are very different in nature, though: Keychain is a generic credentials storage solution, whereas the KeyStore is used to store (and can generate) cryptographic keys, either symmetric keys or public/private keys.
This means that if, for instance, you need to store a session token, on iOS you can let the OS manage the encryption part and just send your token to the Keychain, whereas on Android it’s a bit more of a manual experience because you need to generate (not hard-code, that’s bad) a key, use it to encrypt the token, store the encrypted token in SharedPreferences and store the key in the KeyStore.
There are different approaches to that, as are most things in security, but the simplest is probably to use symmetric encryption, as there is no need for public key cryptography since your app both encrypts and decrypts the token.
Obviously, you don’t need to write mobile platform-specific code that does all of that, as there is a Flutter plugin that does all of that, for instance.
The Lack Of Secure Storage On the Web
That was, actually, the reason that compelled me to write this post. I wrote about using that package to store JWT on mobile apps and people wanted the Web version of that but, as I said, there is no secure storage on the Web. It doesn’t exist.
Does that mean your JWT has to be out in the open?
No, not at all. You can use httpOnly cookies, can’t you? Those aren’t accessible by JS and are sent only to your server. The issue with that is that they’re always sent to your server, even if one of your users clicks on a GET request URL on someone else’s website and that GET request has side effects you or your user won’t like. This actually works for other request types as well, it’s just more complicated. It’s called Cross-Site Request Forgery and you don’t want that. It’s among the web security threats mentioned in Mozilla’s MDN docs, where you can find a more complete explanation.
There are prevention methods. The most common one is having two tokens, actually: one of them getting to the client as an httpOnly cookie, the other as part of the response. The latter has to be stored in localStorage and not in cookies because we don’t want it to be sent automatically to the server.
Solving Both
What if you have both a mobile app and a Web app?
That can be dealt with in one of two ways:
Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, let’s see how we can run different code on different platforms in order to be able to compensate for the differences.
Creating A Flutter Plugin
Especially to solve the problem of storage, one way you can do that is with a plugin package: plugins provide a common Dart interface and can run different code on different platforms, including native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is rather complex, but it’s explained in many places on the Web and elsewhere (for example in Flutter books), including the official Flutter documentation.
For mobile platforms, for instance, there already is a secure storage plugin, and that’s flutter_secure_storage, for which you can find an example of usage here, but that doesn’t work on the Web, for example.
On the other hand, for simple key-value storage that also works on the web, there’s a cross-platform Google-developed first-party plugin package called shared_preferences, which has a Web-specific component called shared_preferences_web which uses NSUserDefaults, SharedPreferences or localStorage depending on the platform.
TargetPlatform on Flutter
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linUX
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
Example 2: Differences In How The Same Widget Is Displayed
You can’t just write cross-platform code and pretend a browser, a phone, a computer, and a smartwatch are the same thing — unless you want your Android and iOS app to be a WebView and your desktop app to be built with Electron. There are plenty of reasons not to do that, and it’s not the point of this piece to convince you to use frameworks like Flutter instead that keep your app native, with all the performance and user experience advantages that come with it, while allowing you to write code that is going to be the same for all platforms most of the time.
That requires care and attention, though, and at least a basic knowledge of the platforms you want to support, their actual native APIs, and all of that. React Native users need to pay even more attention to that because that framework uses the built-in OS widgets, so you actually need to pay even more attention to how the app looks by testing it extensively on both platforms, without being able to switch between iOS and Material widget on the fly like it’s possible with Flutter.
What Changes Without Your Request
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Between Android And iOS (Flutter)
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), but what it DOESN’T do is show exactly the same thing on Android and iOS: Material theming especially adapts to the conventions of each platform.
For instance, navigation animations and transitions and default fonts are different, but those don’t impact your app that much.
What may affect some of your choices when it comes to aesthetics or UX is the fact that some static elements also change. Specifically, some icons change between the two platforms, app bar titles are in the middle on iOS and on the left on Android (on the left of the available space in case there is a back button or the button to open a Drawer (explained here in the Material Design guidelines and also known as a hamburger menu). Here’s what a Material app with a Drawer looks like on Android:
Material app running on Android: the AppBar title is in the left side of the available space. (Large preview)
And what the same, very simple, Material app looks like on iOS:
Material app running on iOS: the AppBar title is in the middle. (Large preview)
Between Mobile and Web and With Screen Notches (Flutter)
On the Web there is a bit of a different situation, as mentioned also in this Smashing article about Responsive Web Development with Flutter: in particular, in addition to having to optimize for bigger screens and account for the way people expect to navigate through your site — which is the main focus of that article — you have to worry about the fact that sometimes widgets are placed outside of the browser window. Also, some phones have notches in the top part of their screen or other impediments to the correct viewing of your app because of some sort of obstruction.
Both of these problems can be avoided by wrapping your widgets in a SafeArea widget, which is a particular kind of padding widget which makes sure your widgets fall into a place where they can actually be displayed without anything impeding the users’ ability to see them, be it a hardware or software constraint.
In React Native
React Native requires much more attention and a much deeper knowledge of each platform, in addition to requiring you to run the iOS Simulator as well as the Android Emulator at the very least in order to be able to test your app on both platforms: it’s not the same and it converts its JavaScript UI elements to platform-specific widgets. In other words, your React Native apps will always look like iOS — with Cupertino UI elements as they are sometimes called — and your Android apps will always look like regular Material Design Android apps because it’s using the platform’s widgets.
The difference here is that Flutter renders its widgets with its own low-level rendering engine, which means you can test both app versions on one platform.
Getting Around That Issue
Unless you’re going for something very specific, your app is supposed to look different on different platforms otherwise some of your users will be unhappy.
Just like you shouldn’t simply ship a mobile app to the web (as I wrote in the aforementioned Smashing post), you shouldn’t ship an app full of Cupertino widgets to Android users, for example, because it’s going to be confusing for the most part. On the other hand, having the chance to actually run an app that has widgets that are meant for another platform allows you to test the app and show it to people in both versions without having to use two devices for that necessarily.
The Other Side: Using The Wrong Widgets For The Right Reasons
But that also means that you can do most of your Flutter development on a LinUX or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps
Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.
It’s great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
Further Resources
(ra, yk, il)
Website Design & SEO Delray Beach by DBL07.co
Delray Beach SEO
source http://www.scpie.org/solving-common-cross-platform-issues-when-working-with-flutter/ source https://scpie.tumblr.com/post/621342349322289152
0 notes
Text
Solving Common Cross-Platform Issues When Working With Flutter
About The Author
Flutter and LinUX enthusiast, author of the Programming Flutter book with the Pragmatic Bookshelf. Blogs more, tweets less. More about Carmine …
When using cross-platform frameworks, people might forget the nuances of each of the platforms they want their code to run on. This article aims to address that.
I’ve seen a lot of confusion online regarding Web development with Flutter and, often, it’s sadly for the wrong reasons.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isn’t that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
In this article, we’re going to see some of those differences and how to overcome them. More specifically, we’re going to talk about storage and UI differences, which are the ones that most often cause confusion to developers when writing Flutter code that they want to be cross-platform.
Example 1: Storage
I recently wrote on my blog about the need for a different approach to storing JWTs in Web apps when compared to mobile apps.
That is because of the different nature of the platforms’ storage options, and the need to know each and their native development tools.
Web
When you write a Web app, the storage options you have are:
downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user;
using cookies, which may or may not be accessible from JS (depending on whether or not they’re httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response;
using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
Mobile
The situation when it comes to mobile apps is completely different. The storage options are the following:
local app documents or cache storage, accessible by that app;
other local storage paths for user-created/readable files;
NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage;
Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
If you don’t know that, you’re going to make a mess of your implementations because you need to know what storage solution you’re actually using and what the advantages and drawbacks are.
Cross-Platform Solutions: An Initial Approach
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android and NSUserDefaults on iOS. Those have completely different implications for your app, especially if you’re storing sensitive information like session tokens: localStorage can be read by the client, so it’s a problem if you’re vulnerable to XSS. Even though mobile apps aren’t really vulnerable to XSS, SharedPreferences and NSUserDefaults are not secure storage methods because they can be compromised on the client side since they are not secure storage and not encrypted. That’s because they are meant for user preferences, as mentioned here in the case of iOS and here in the Android documentation when talking about the Security library which is designed to provide wrappers to the SharedPreferences specifically to encrypt the data before storing it.
Secure Storage On Mobile
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web.
The Keychain and KeyStore are very different in nature, though: Keychain is a generic credentials storage solution, whereas the KeyStore is used to store (and can generate) cryptographic keys, either symmetric keys or public/private keys.
This means that if, for instance, you need to store a session token, on iOS you can let the OS manage the encryption part and just send your token to the Keychain, whereas on Android it’s a bit more of a manual experience because you need to generate (not hard-code, that’s bad) a key, use it to encrypt the token, store the encrypted token in SharedPreferences and store the key in the KeyStore.
There are different approaches to that, as are most things in security, but the simplest is probably to use symmetric encryption, as there is no need for public key cryptography since your app both encrypts and decrypts the token.
Obviously, you don’t need to write mobile platform-specific code that does all of that, as there is a Flutter plugin that does all of that, for instance.
The Lack Of Secure Storage On the Web
That was, actually, the reason that compelled me to write this post. I wrote about using that package to store JWT on mobile apps and people wanted the Web version of that but, as I said, there is no secure storage on the Web. It doesn’t exist.
Does that mean your JWT has to be out in the open?
No, not at all. You can use httpOnly cookies, can’t you? Those aren’t accessible by JS and are sent only to your server. The issue with that is that they’re always sent to your server, even if one of your users clicks on a GET request URL on someone else’s website and that GET request has side effects you or your user won’t like. This actually works for other request types as well, it’s just more complicated. It’s called Cross-Site Request Forgery and you don’t want that. It’s among the web security threats mentioned in Mozilla’s MDN docs, where you can find a more complete explanation.
There are prevention methods. The most common one is having two tokens, actually: one of them getting to the client as an httpOnly cookie, the other as part of the response. The latter has to be stored in localStorage and not in cookies because we don’t want it to be sent automatically to the server.
Solving Both
What if you have both a mobile app and a Web app?
That can be dealt with in one of two ways:
Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, let’s see how we can run different code on different platforms in order to be able to compensate for the differences.
Creating A Flutter Plugin
Especially to solve the problem of storage, one way you can do that is with a plugin package: plugins provide a common Dart interface and can run different code on different platforms, including native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is rather complex, but it’s explained in many places on the Web and elsewhere (for example in Flutter books), including the official Flutter documentation.
For mobile platforms, for instance, there already is a secure storage plugin, and that’s flutter_secure_storage, for which you can find an example of usage here, but that doesn’t work on the Web, for example.
On the other hand, for simple key-value storage that also works on the web, there’s a cross-platform Google-developed first-party plugin package called shared_preferences, which has a Web-specific component called shared_preferences_web which uses NSUserDefaults, SharedPreferences or localStorage depending on the platform.
TargetPlatform on Flutter
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linUX
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
Example 2: Differences In How The Same Widget Is Displayed
You can’t just write cross-platform code and pretend a browser, a phone, a computer, and a smartwatch are the same thing — unless you want your Android and iOS app to be a WebView and your desktop app to be built with Electron. There are plenty of reasons not to do that, and it’s not the point of this piece to convince you to use frameworks like Flutter instead that keep your app native, with all the performance and user experience advantages that come with it, while allowing you to write code that is going to be the same for all platforms most of the time.
That requires care and attention, though, and at least a basic knowledge of the platforms you want to support, their actual native APIs, and all of that. React Native users need to pay even more attention to that because that framework uses the built-in OS widgets, so you actually need to pay even more attention to how the app looks by testing it extensively on both platforms, without being able to switch between iOS and Material widget on the fly like it’s possible with Flutter.
What Changes Without Your Request
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Between Android And iOS (Flutter)
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), but what it DOESN’T do is show exactly the same thing on Android and iOS: Material theming especially adapts to the conventions of each platform.
For instance, navigation animations and transitions and default fonts are different, but those don’t impact your app that much.
What may affect some of your choices when it comes to aesthetics or UX is the fact that some static elements also change. Specifically, some icons change between the two platforms, app bar titles are in the middle on iOS and on the left on Android (on the left of the available space in case there is a back button or the button to open a Drawer (explained here in the Material Design guidelines and also known as a hamburger menu). Here’s what a Material app with a Drawer looks like on Android:
Material app running on Android: the AppBar title is in the left side of the available space. (Large preview)
And what the same, very simple, Material app looks like on iOS:
Material app running on iOS: the AppBar title is in the middle. (Large preview)
Between Mobile and Web and With Screen Notches (Flutter)
On the Web there is a bit of a different situation, as mentioned also in this Smashing article about Responsive Web Development with Flutter: in particular, in addition to having to optimize for bigger screens and account for the way people expect to navigate through your site — which is the main focus of that article — you have to worry about the fact that sometimes widgets are placed outside of the browser window. Also, some phones have notches in the top part of their screen or other impediments to the correct viewing of your app because of some sort of obstruction.
Both of these problems can be avoided by wrapping your widgets in a SafeArea widget, which is a particular kind of padding widget which makes sure your widgets fall into a place where they can actually be displayed without anything impeding the users’ ability to see them, be it a hardware or software constraint.
In React Native
React Native requires much more attention and a much deeper knowledge of each platform, in addition to requiring you to run the iOS Simulator as well as the Android Emulator at the very least in order to be able to test your app on both platforms: it’s not the same and it converts its JavaScript UI elements to platform-specific widgets. In other words, your React Native apps will always look like iOS — with Cupertino UI elements as they are sometimes called — and your Android apps will always look like regular Material Design Android apps because it’s using the platform’s widgets.
The difference here is that Flutter renders its widgets with its own low-level rendering engine, which means you can test both app versions on one platform.
Getting Around That Issue
Unless you’re going for something very specific, your app is supposed to look different on different platforms otherwise some of your users will be unhappy.
Just like you shouldn’t simply ship a mobile app to the web (as I wrote in the aforementioned Smashing post), you shouldn’t ship an app full of Cupertino widgets to Android users, for example, because it’s going to be confusing for the most part. On the other hand, having the chance to actually run an app that has widgets that are meant for another platform allows you to test the app and show it to people in both versions without having to use two devices for that necessarily.
The Other Side: Using The Wrong Widgets For The Right Reasons
But that also means that you can do most of your Flutter development on a LinUX or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps
Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.
It’s great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
Further Resources
(ra, yk, il)
Website Design & SEO Delray Beach by DBL07.co
Delray Beach SEO
source http://www.scpie.org/solving-common-cross-platform-issues-when-working-with-flutter/
0 notes