larryaasen / upgrader

A Flutter package for prompting users to upgrade when there is a newer version of the app in the store.
MIT License
547 stars 268 forks source link

Upgrader possibly queries the wrong bundleId on iOS #250

Closed proxy2501 closed 5 months ago

proxy2501 commented 1 year ago

Hi, I'm having an issue with getting a good response from the Apple Store, and I suspect it has to do with the package name that is being used to make the query.

Background

We originally decided on an application id based on the (apparent) convention of naming Flutter apps with underscores. So our app's applicationID in ./android/app/build.gradle ended up being com.[company].xxx_yyy_zzz:

defaultConfig {
        applicationId "com.[company].xxx_yyy_zzz"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

However, when we later tried to release on Apple Store, we were unable to use this as our bundle id, because underscores are not allowed.

So we chose the following bundle id instead: com.[company].xxxYyyZzz

This works fine in-so-far as simply specifying this as our PRODUCT_BUNDLE_IDENTIFIER in ./ios/Runner.xcodeproj/project.pbxproj instead. The app compiles and releases just fine, and is currently released on both Google Play and Apple Store with these settings.

The problem

We have created an instance of Upgrader and provided it to an UpgradeAlert inside of the Widget tree as described in the readme.

We have tested and confirmed that this works correctly on Android with newer versions on Google Play. The Upgrader queries the Google Play version and gets a good response.

These are the debug logs when running on Android:

I/flutter ( 4832): upgrader: build UpgradeAlert
I/flutter ( 4832): upgrader: languageCode: en
I/flutter ( 4832): upgrader: default operatingSystem: android RSR1.201013.001
I/flutter ( 4832): upgrader: operatingSystem: android
I/flutter ( 4832): upgrader: platform: TargetPlatform.android
I/flutter ( 4832): upgrader: isAndroid: true, isIOS: false, isLinux: false, isMacOS: false, isWindows: false, isFuchsia: false, isWeb: false
I/flutter ( 4832): upgrader: package info packageName: com.[company].xxx_yyy_zzz
I/flutter ( 4832): upgrader: package info appName: [app name]
I/flutter ( 4832): upgrader: package info version: 1.0.12
I/flutter ( 4832): upgrader: countryCode: US
I/flutter ( 4832): upgrader: languageCode: en
I/flutter ( 4832): upgrader: blocked: false
I/flutter ( 4832): upgrader: debugDisplayAlways: false
I/flutter ( 4832): upgrader: debugDisplayOnce: false
I/flutter ( 4832): upgrader: hasAlerted: false
I/flutter ( 4832): upgrader: appStoreVersion: 1.0.12
I/flutter ( 4832): upgrader: installedVersion: 1.0.12
I/flutter ( 4832): upgrader: minAppVersion: null
I/flutter ( 4832): upgrader: isUpdateAvailable: false
I/flutter ( 4832): upgrader: shouldDisplayUpgrade: false
I/flutter ( 4832): upgrader: shouldDisplayReleaseNotes: true

However, on iOS the Upgrader seems to think that the packageName is still supposed to be com.[company].xxx_yyy_zzz and not com.[company].xxxYyyZzz

Since I have not been able to find a way of ascertaining which bundleId is actually being used during runtime, I can only speculate that the Upgrader is asking for the incorrect bundleId when running on iOS, because of this "dual id" situation.

These are the debug logs when setting Upgrader.platform to platform: TargetPlatform.iOS:

I/flutter ( 4832): upgrader: build UpgradeAlert
I/flutter ( 4832): upgrader: languageCode: en
I/flutter ( 4832): upgrader: default operatingSystem: android RSR1.201013.001
I/flutter ( 4832): upgrader: operatingSystem: android
I/flutter ( 4832): upgrader: platform: TargetPlatform.iOS
I/flutter ( 4832): upgrader: isAndroid: true, isIOS: false, isLinux: false, isMacOS: false, isWindows: false, isFuchsia: false, isWeb: false
I/flutter ( 4832): upgrader: package info packageName: com.[company].xxx_yyy_zzz
I/flutter ( 4832): upgrader: package info appName: [app name]
I/flutter ( 4832): upgrader: package info version: 1.0.12
I/flutter ( 4832): upgrader: countryCode: US
I/flutter ( 4832): upgrader: languageCode: en
I/flutter ( 4832): upgrader.ITunesResults.version: RangeError (index): Invalid value: Valid value range is empty: 0
I/flutter ( 4832): upgrader.ITunesResults.trackViewUrl: RangeError (index): Invalid value: Valid value range is empty: 0
I/flutter ( 4832): upgrader.ITunesResults.releaseNotes: RangeError (index): Invalid value: Valid value range is empty: 0
I/flutter ( 4832): upgrader.ITunesResults.description: RangeError (index): Invalid value: Valid value range is empty: 0
I/flutter ( 4832): upgrader: blocked: false
I/flutter ( 4832): upgrader: debugDisplayAlways: false
I/flutter ( 4832): upgrader: debugDisplayOnce: false
I/flutter ( 4832): upgrader: hasAlerted: false
I/flutter ( 4832): upgrader: appStoreVersion: null
I/flutter ( 4832): upgrader: installedVersion: 1.0.12
I/flutter ( 4832): upgrader: minAppVersion: null
I/flutter ( 4832): upgrader: isUpdateAvailable: false
I/flutter ( 4832): upgrader: shouldDisplayUpgrade: false
I/flutter ( 4832): upgrader: shouldDisplayReleaseNotes: false

I have also tried manually querying iTunes using the (correct) bundleId, and this seems to give a good response:

PS D:\***> dart .\bin\itunes_lookup.dart bundleid=com.[company].xxxYyyZzz
upgrader: download: https://itunes.apple.com/lookup?bundleId=com.[company].xxxYyyZzz&country=US&_cb=1671798673978320
upgrader: response statusCode: 200
itunes_lookup bundleId: com.[company].xxxYyyZzz
itunes_lookup description: ***
itunes_lookup minAppVersion: null
itunes_lookup releaseNotes: ***
itunes_lookup trackViewUrl: https://apps.apple.com/us/app/xxx-yyy-zzz/id6444800056?uo=4
itunes_lookup version: 1.0.12
itunes_lookup all results:
{resultCount: 1, results: [{screenshotUrls: [https://is4-ssl.mzstatic.com/image/thumb/PurpleSource112/v4/8a/0e/e0/8a0ee00f-7bc6-c054-0604-3e37d2517ed3/a27ea688-ee0d-4b1f-a251-9bc7b7b09dea_Simulator_Screen_Shot_-_iPhone_8_Plus_-_2022-11-30_at_14.03.56.png/392x696bb.png, https://is4-ssl.mzstatic.com/image/thumb/PurpleSource122/v4/41/9d/09/419d095a-41e9-8dcb-562e-1ffffbbc1fe3/029ffcac-6251-46fa-907b-1ebc1a3c76f1_Simulator_Screen_Shot_-_iPhone_8_Plus_-_2022-11-30_at_14.17.13.png/392x696bb.png, https://is1-ssl.mzstatic.com/image/thumb/PurpleSource112/v4/44/c7/c3/44c7c365-514a-0cde-6b8a-0501e3e73a95/2a2a3855-6eeb-4f6f-a9a4-317f1aee3ca4_Simulator_Screen_Shot_-_iPhone_8_Plus_-_2022-11-30_at_14.05.11.png/392x696bb.png], isGameCenterEnabled: false, features: [iosUniversal], advisories: [], supportedDevices: [iPhone5s-iPhone5s, iPadAir-iPadAir, iPadAirCellular-iPadAirCellular, iPadMiniRetina-iPadMiniRetina, iPadMiniRetinaCellular-iPadMiniRetinaCellular, iPhone6-iPhone6, iPhone6Plus-iPhone6Plus, iPadAir2-iPadAir2, iPadAir2Cellular-iPadAir2Cellular, iPadMini3-iPadMini3, iPadMini3Cellular-iPadMini3Cellular, iPodTouchSixthGen-iPodTouchSixthGen, iPhone6s-iPhone6s, iPhone6sPlus-iPhone6sPlus, iPadMini4-iPadMini4, iPadMini4Cellular-iPadMini4Cellular, iPadPro-iPadPro, iPadProCellular-iPadProCellular, iPadPro97-iPadPro97, iPadPro97Cellular-iPadPro97Cellular, iPhoneSE-iPhoneSE, iPhone7-iPhone7, iPhone7Plus-iPhone7Plus, iPad611-iPad611, iPad612-iPad612, iPad71-iPad71, iPad72-iPad72, iPad73-iPad73, iPad74-iPad74, iPhone8-iPhone8, iPhone8Plus-iPhone8Plus, iPhoneX-iPhoneX, iPad75-iPad75, iPad76-iPad76, iPhoneXS-iPhoneXS, iPhoneXSMax-iPhoneXSMax, iPhoneXR-iPhoneXR, iPad812-iPad812, iPad834-iPad834, iPad856-iPad856, iPad878-iPad878, iPadMini5-iPadMini5, iPadMini5Cellular-iPadMini5Cellular, iPadAir3-iPadAir3, iPadAir3Cellular-iPadAir3Cellular, iPodTouchSeventhGen-iPodTouchSeventhGen, iPhone11-iPhone11, iPhone11Pro-iPhone11Pro, iPadSeventhGen-iPadSeventhGen, iPadSeventhGenCellular-iPadSeventhGenCellular, iPhone11ProMax-iPhone11ProMax, iPhoneSESecondGen-iPhoneSESecondGen, iPadProSecondGen-iPadProSecondGen, iPadProSecondGenCellular-iPadProSecondGenCellular, iPadProFourthGen-iPadProFourthGen, iPadProFourthGenCellular-iPadProFourthGenCellular, iPhone12Mini-iPhone12Mini, iPhone12-iPhone12, iPhone12Pro-iPhone12Pro, iPhone12ProMax-iPhone12ProMax, iPadAir4-iPadAir4, iPadAir4Cellular-iPadAir4Cellular, iPadEighthGen-iPadEighthGen, iPadEighthGenCellular-iPadEighthGenCellular, iPadProThirdGen-iPadProThirdGen, iPadProThirdGenCellular-iPadProThirdGenCellular, iPadProFifthGen-iPadProFifthGen, iPadProFifthGenCellular-iPadProFifthGenCellular, iPhone13Pro-iPhone13Pro, iPhone13ProMax-iPhone13ProMax, iPhone13Mini-iPhone13Mini, iPhone13-iPhone13, iPadMiniSixthGen-iPadMiniSixthGen, iPadMiniSixthGenCellular-iPadMiniSixthGenCellular, iPadNinthGen-iPadNinthGen, iPadNinthGenCellular-iPadNinthGenCellular, iPhoneSEThirdGen-iPhoneSEThirdGen, iPadAirFifthGen-iPadAirFifthGen, iPadAirFifthGenCellular-iPadAirFifthGenCellular, iPhone14-iPhone14, iPhone14Plus-iPhone14Plus, iPhone14Pro-iPhone14Pro, iPhone14ProMax-iPhone14ProMax, iPadTenthGen-iPadTenthGen, iPadTenthGenCellular-iPadTenthGenCellular, iPadPro11FourthGen-iPadPro11FourthGen, iPadPro11FourthGenCellular-iPadPro11FourthGenCellular, iPadProSixthGen-iPadProSixthGen, iPadProSixthGenCellular-iPadProSixthGenCellular], kind: software, ipadScreenshotUrls: [https://is2-ssl.mzstatic.com/image/thumb/PurpleSource112/v4/3d/ac/17/3dac173c-7761-2a9e-a2cf-6efd57d8320a/e9f00ead-1bea-43f0-8165-33fbb6bdfa83_Simulator_Screen_Shot_-_iPad_Pro__U002812.9-inch_U0029__U00286th_generation_U0029_-_2022-11-30_at_14.08.24.png/576x768bb.png, 
https://is3-ssl.mzstatic.com/image/thumb/PurpleSource112/v4/47/c1/ed/47c1ed30-28fc-bde3-b8a1-079e0733cfd3/56e41b2a-b9b1-4b02-b0bd-328eb4c55d04_Simulator_Screen_Shot_-_iPad_Pro__U002812.9-inch_U0029__U00286th_generation_U0029_-_2022-11-30_at_14.08.16.png/576x768bb.png, https://is3-ssl.mzstatic.com/image/thumb/PurpleSource112/v4/c1/0d/22/c10d2202-0091-38ff-0bf9-2d48691fde76/ec1365d5-e3c6-432f-8f1c-c0dab7374c4e_Simulator_Screen_Shot_-_iPad_Pro__U002812.9-inch_U0029__U00286th_generation_U0029_-_2022-11-30_at_14.07.59.png/576x768bb.png], appletvScreenshotUrls: [], artworkUrl60: https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/fa/e1/da/fae1da16-ec5a-58d0-5a33-cfc138767ef7/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/60x60bb.jpg, artworkUrl512: https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/fa/e1/da/fae1da16-ec5a-58d0-5a33-cfc138767ef7/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/512x512bb.jpg, artworkUrl100: https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/fa/e1/da/fae1da16-ec5a-58d0-5a33-cfc138767ef7/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.jpg, artistViewUrl: https://apps.apple.com/us/developer/[company]/id1656936717?uo=4, trackCensoredName: ***, minimumOsVersion: 12.0, languageCodesISO2A: [EN], fileSizeBytes: 32304128, formattedPrice: Free, contentAdvisoryRating: 4+, averageUserRatingForCurrentVersion: 0, userRatingCountForCurrentVersion: 0, averageUserRating: 0, trackViewUrl: https://apps.apple.com/us/app/xxx-yyy-zzz/id6444800056?uo=4, trackContentRating: 4+, currentVersionReleaseDate: 2022-12-22T17:08:52Z, releaseNotes: Added two colour schemes with dark mode support.
Dark and light modes match global device settings.

Fixed launcher icon appearance on iOS., artistId: 1656936717, artistName: [company], genres: [Business, Utilities], price: 0.0, description: ***, genreIds: [6000, 6002], primaryGenreName: Business, primaryGenreId: 6000, bundleId: com.[company].xxxYyyZzz, sellerName: [company], isVppDeviceBasedLicensingEnabled: true, releaseDate: 2022-12-01T08:00:00Z, trackId: 6444800056, trackName: [app name], version: 1.0.12, wrapperType: software, currency: USD, userRatingCount: 0}]}

Relevant project settings

Our Upgrader instance is set up with the following values:

final Upgrader upgrader = Upgrader(
    countryCode: 'US',
    dialogStyle: !kIsWeb && Platform.isIOS
        ? UpgradeDialogStyle.cupertino
        : UpgradeDialogStyle.material,
    durationUntilAlertAgain: const Duration(days: 3),
  );

Our project's upgrader dependency is as follows:

dependencies:
  flutter:
    sdk: flutter
  ...
  upgrader: ^5.0.0

Am I right in assuming that the incorrect bundleId is being used to query the iTunes store?

And if so, would an easy fix be to let us explicitly specify which bundleId to ask for inside of the Upgrader constructor?

Thank you for your time.

larryaasen commented 10 months ago

@proxy2501 Is this still an issue?