Vithani Chandresh
Vithani Chandresh

Reputation: 831

How to get bundle id in flutter

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;
        });
      }

Upvotes: 64

Views: 94694

Answers (6)

Yogi Arif Widodo
Yogi Arif Widodo

Reputation: 679

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.

Upvotes: 1

Technorocker
Technorocker

Reputation: 139

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

Upvotes: 1

Paul
Paul

Reputation: 1865

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

Upvotes: 4

Kab Agouda
Kab Agouda

Reputation: 7269

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

Upvotes: 2

Mohsen Emami
Mohsen Emami

Reputation: 3142

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.

Upvotes: 14

Suragch
Suragch

Reputation: 511736

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

Upvotes: 141

Related Questions