How to detect Apple User Agents in a Flutter web app? - flutter

I'm making a cross-platform mobile app with Flutter targeting iOS, Android and Web. I want to show the Cupertino theme to users of Apple devices and the Material (3) theme to users of all other devices.
As for iOS and Android builds, I detect the OS using the Universal Platform library and present the corresponding theme, no problem with that. However, as for the Web builds, I would like to detect the OS using the User Agent string.
By "users of Apple devices" I mean users who open my app on either macOS, iOS or iPadOS (or any other OS by Apple I missed, if possible), regardless of their browser. I would also include users of other OSs who specifically changed their User Agent string to make it look like they're using an Apple device, as I think it's safe to assume that they would prefer (or at least expect) to see the Cupertino theme; and I would exclude those who did the opposite, for the same reasons.
What would be the best way to detect such "Apple device users" in my Flutter Web app via User Agent? Right now I'm inclined to just look for /Mac/ in the User Agent string, but I'm afraid of getting many false positives. Thank you!

Try this package from pub.dev: https://pub.dev/packages/web_browser_detect
This example is what you are looking for:
import 'package:web_browser_detect/web_browser_detect.dart';
void main() {
final browser = Browser.detectFrom(userAgent: userAgent, vendor: vendor, appVersion: appVersion);
print('${browser.browser} ${browser.version}');
}

Related

Is it possible to see if PWA was installed from the APP Store vs. Mobile Browsing?

At the moment my Mobile experience is m-web and my app is PWA (app stores) ... but I want to join the two and just have PWA.
But I need to differentiate between the App Store download and the Mobile download - at least for the first few usages. (i.e. if someone downloads from the app store, I want to "hide" certain content until they have purchased, however if they access direct from mobile, they can have the content directly.)
Is this possible with PWA - to see if the version they have was downloaded from the APP store vs downloaded through mobile browsing?
You do not need to submit your PWA to the app store. Users can just access it directly.
You can wrap your PWA in a hybrid shell, something like the soon to be deprecated Cordova for example. If you do this, I believe there would be some sort of flag to check if the shell is present.
Apple is known for rejecting and removing hybrid apps, just FYI. This one reason why so many brands are abandoning native apps.
It feels like you are doing something of #3.
I get why you want users to pay through your web interface, the 30% tax is repressive. But doing this will most likely get you tossed from the app store. This is the foundation of BaseCamp's complaints.
https://love2dev.com/apple-appstore-pwa/
if (window.matchMedia('(display-mode: standalone)').matches) {
console.log("This is running as standalone.");
}
Sure you need to edit standalone if you use some other display property

How to disable other Apps or other apps communication with Ionic

I am looking for information on how to disable/enable other apps with Ionic. Or even block the network communication of another app through a button in my ionic app.
Is this possible with Ionic? What plugins or tools should I look for?
Thank you!
Such privileges in general are reserved with the system (operating system) and each app including ionic-cordova hybrid would run in a "sandbox" and app 2 app APIs are normally not common or not available/exposed.
There was an attempt to do app2app API with windows phone but failed.
So at best you could try leverage app specific schemas to let OS know you want external app to do something. But definitely you can't control other app's behavior like you described (was possible in early days of Android actually I think)

Smart TV App SDKs and support of auto start and auto update

I'm a newbe in SmartTV app development and trying to figure out if the related devices (SmartTVs) through their SDKs of the two major vendors Samsung and LG support the following when it comes to a custom implemented app:
Is it possible to auto start the app on TV start/restart? and if yes
how? Does someone know any reference in their APIs of how it is done?
if there is a newer version of my app how does the updates takes
place? Is it possible to automatically update the app or at least
send some short of notification for software update needed?
Thanks in advance
I add some notes:
auto start is possible in some countries on Samsung as ticker app. This ticker app is available only in some countries (I think in Korea and U.S., but I am not sure). If you want ticker app you can switch samsung to the "hotel mode" in the samsung service menu.
auto update is available when you set the flag in config.xml
<autoUpdate itemtype="boolean">y</autoUpdate>
There is no way to achieve autostart in SDK distributed by vendors.
But there is at least one app, that starts with TV (Some European
IPTV provider, can't remember name). You need to contact with
vendors support and find out for yourself.
Samsung apps distributed
and updated through its store, you upload updated version on seller
portal and its distributed on tv. Users are prompted to update app
when new version is available.
LG hosted apps you can update yourself, packaged apps - same as with Samsung.

How can I make my own iPhone app for myself?

I don't have an Apple computer, I just have an iPhone and some knowledge about language development. I want to create my own app for my own use, just for fun! I don't want to pay Apple for a developer account. I just want to develop my app and put it on my iPhone. I can either develop on Linux or Windows. How can I do that?
If you want to develop on an actual iPhone, you'll need a developer licence. To developer apps natively you will need a Mac running XCode.
There's lots of HTML5 libraries for making apps using javascript though. Maybe try out Phonegap or GameSalad
At the minimum you'll need to have OSX (Mac Operating system) to run Xcode/iphone emulator, you wont be able to do this without OSX.
EDIT:
You may be able to develop it using phone gap: http://phonegap.com/
You'll have to do testing on an adriod emulator, but I believe phonegap builds the app in the cloud. Good luck.
You can develop an app using adobe AIR or adobe Flash. Check out FlashDevelop for a free solution for making flash and air apps for everything from windows to android to iOS.
For a somewhat detailed tutorial on how to actually export an AIR project from FlashDevelop so you can install it on an iOS device, see:
http://www.codeandvisual.com/2011/exporting-for-iphone-using-air-27-and-flashdevelop-part-one-installation/
and FYI, this is not JUST for jailbroken iOS devices! :D
Native iOS applications can only be built in Xcode (which can only run on a Mac), and you need a developer membership to deploy those on an actual device (which costs about $100 a year). So, that’s the caveat: You can’t make native apps.
However, native apps aren’t the only option! There are two other approaches.
One way is to make a web app. These days, web apps can do almost everything that a native app can do (even access the camera). Unless you’re building something specialized (like a video editor, for example, or a game that needs to work with Bluetooth game controllers), you can probably make something as a web app. Years ago, I wasn’t happy with the flashcard apps on the market and wanted something custom but super simple to help me study JLPT vocabulary. At the time, I also didn’t have the money for a developer membership. I made it as a web app, and it worked great!
If you’re making a web app, you’ll need someplace to host it. There are lots of options. For example, the free tier on Firebase is plenty for a personal-use web app. You also might want to consider building the app using client-side scripting (like Javascript) so that you can host it statically, which will allow you to tell iOS to cache it so you can utilize it offline (Google “HTML offline manifest” for details).
The other way, if you have a friend with a developer account, is to build your app using a cross-platform framework like Flutter, where you don’t need a Mac to develop and test it, then ask your friend to make it for you. You’ll need to rebuild periodically (I think once a year) because your provisioning profile will expire.
If you use a framework like Flutter that can build both native AND web apps, that gives you the ability to run natively (if you have access to a Mac) or host it statically on someplace like Firebase Hosting (if you don’t).

How do you build an iPhone App with MobiOne?

I'm using MobiOne to build an App (I don't have a Mac or know Obj-C), but I'm wondering how to compile the App into Obj-C. Has anyone tried this? I have my design done and tested in the emulator, but do not see how to build the code.
My understanding is that MobiOne is not designed to be uploaded to Apple's app store. You can use Phone Gap to help get your app into a native environment since MobiOne uses web technologies. Phone Gap should allow you to publish to the app store, but the app is still subject to Apple's quality control system.
EDIT: You will still need a mac to publish the app. Or you can just use the app as a website on your device(s).
You can build the app with the Mobione built-in compiler. Go to the "Project" menu and click "Build iOS app" and your app will be compiled. You cannot compile with Obj-C.
Compile it into an iOS native app using Mobione on Windows. Upload it to the App Store using Apple's Application Uploader on a Mac. Easy.
According to Apple, you are not supposed to make iPhone apps without a mac. Also learning objective c MIGHT just be a good first start before making an app.
The first comment in your question provides a link, and one of the first paragraphs in that link states this:
"The traditional approach to iOS application development requires developers to create their apps using Apple’s Objective-C programming tools and Macintosh(tm) hardware. MobiOne runs on your Windows OS (Win7 to XP) hardware and offers developers an alternative cross-platform programming model based on HTML5 open web standards and virtual device services, e.g., contacts, camera, audio... "
Of course this allows you to do it, but that doesn't mean that the appstore will accept your app if you try and submit it through MobiOne. I'm not too sure on the subject, but I would do some research and figure out if apple allows you to do this.