59

I used the below method to get the app name and packageName but I need Bundle id for iPhone users. I want to share an app link. I did it in android but on iPhone, I need bundle id.

 Future<Null> _initPackageInfo() async {
        final PackageInfo info = await PackageInfo.fromPlatform();
        setState(() {
          _packageInfo = info;
          packageName = info.packageName;
          appName = info.appName;
          buildNumber = info.buildNumber;
        });
      }
Vithani Chandresh
  • 781
  • 1
  • 6
  • 9

6 Answers6

130

To find the project name manually, you can look in AndroidManifest.xml or in Info.plist.

Android

In Android the package name is in the AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    package="com.example.appname">

iOS

In iOS the package name is the bundle identifier in Info.plist:

<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

which is found in Runner.xcodeproj/project.pbxproj:

PRODUCT_BUNDLE_IDENTIFIER = com.example.appname;

See also

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
14

In iOS portion of a Flutter project Product Bundle Identifier is in project.pbxproj file in path:

[your-flutter-project-dir]\ios\Runner.xcodeproj\project.pbxproj

and that is specified as following:

PRODUCT_BUNDLE_IDENTIFIER = com.app.flutter.example;

Note in that this value is same as Android Package Name in Flutter projects.

Mohsen Emami
  • 2,709
  • 3
  • 33
  • 40
4

If you just need to get the IOS bundle ID manually, here is how

  1. In Android Studio select the root folder (ex. flutte_name)
  2. In the taskbar go to Tools>>Flutter>>Open IOS Modules in Xcode
  3. In Xcode open Runner and under Identity/Bundle Identifier there is your ID

enter image description here

Paul
  • 1,349
  • 1
  • 14
  • 26
  • How can I get IOS bundle ID if I am using android studio on windows 11? – pawan Feb 03 '22 at 05:54
  • 1
    @pawan As far as I am concerned Xcode requires a Mac/macOS. If you have windows I would probably go for [this](https://stackoverflow.com/a/55128145/11003497) answer. – Paul Feb 03 '22 at 09:02
1

You probably want to update it to a custom name rather than com.example.appName anyways so you can check out this package called change_app_name on pub.dev here https://pub.dev/packages/change_app_package_name

Super simple I just did it myself. Add the package to your pubspec file and than in a terminal in the root folder type in "flutter pub run change_app_package_name:main com.company.app" change the last part to whatever you want and it will update your whole project with the new name you chose

Technorocker
  • 103
  • 14
  • I think this answer belongs over here:https://stackoverflow.com/questions/51534616/how-to-change-package-name-in-flutter instead. – Jeff Feb 08 '22 at 02:11
1

what i see you have already get the package name by info.packageName; and appName info.appName;

  1. try request to http://itunes.apple.com/search?media=software&country={countryID}&term={appName}
  2. you can test by curl instead of browser ( this will return file.txt )
curl --location -g --request GET 'http://itunes.apple.com/search?media=software&country=id&term=appName' \
--header 'Accept: application/json' | jq

in other solution some people can get it from

// if doesnt work try with these lookup
itunes.apple.com/lookup?bundleId=com.apple.Pages
 | jq // these for make response beutifull

response json

....
....
bundleId: '212312xxxxxx'
trackViewUrl: 'https://apps.apple.com/id/app/appName/id212312xxxxxx'
....
....

i use these concept to self update from backend ( SplashScreen / check app version ) will popUP alert forced user to go to the market place.

Yogi Arif Widodo
  • 563
  • 6
  • 22
0

Use get_version package . It's the easiest way

Installing :

 dependencies:
   get_version: any

Usage:

String projectAppID;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
  projectAppID = await GetVersion.appID;
} on PlatformException {
  projectAppID = 'Failed to get app ID.';
}

You can use it as String inside anything you want like Text widget etc ...


Another extract of get_version in a small application :

import 'package:get_version/get_version.dart';    
  class _MyAppState extends State<MyApp> {
  String _projectAppID = '';
  @override
  initState() {
    super.initState();
    initPlatformState();
  }    
  // Platform messages are asynchronous, so we initialize in an async method.
  initPlatformState() async {
    String projectAppID;
    try {
      projectAppID = await GetVersion.appID;
    } catch (e) {
      projectAppID = 'Failed to get app ID.';
    }
    setState(() {
      _projectAppID = projectAppID;
    });
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListTile(
          leading: new Icon(Icons.info),
          title: const Text('App ID'),
          subtitle: new Text(_projectAppID),
        ),
      ),
    );
  }
}

Output :

enter image description here

Kab Agouda
  • 6,309
  • 38
  • 32