Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am stuck how to use this for iOS? #20

Closed
NTMS2017 opened this issue Jan 17, 2020 · 16 comments
Closed

I am stuck how to use this for iOS? #20

NTMS2017 opened this issue Jan 17, 2020 · 16 comments
Assignees
Labels
need more information Further information is requested

Comments

@NTMS2017
Copy link

Hi,

I am trying to use this package for my iOS app which is in App Store. But I am not sure where to start. Is the example file is enough? Or can you post more deatils now not use for iOS. Also I want to force user to update always. how to disable other 2 buttons? Thanks

@NTMS2017
Copy link
Author

NTMS2017 commented Jan 17, 2020

I follow your ITunesSearchAPI Example instruction and I got no result.
Than I use UpgradeAlert to get info for iOS and got another error as shown below;

UpgardeAlert code and error:

    return Scaffold(
        key: _scaffoldKeyLogin,
        backgroundColor: Colors.grey[200],
          body: UpgradeAlert(
          child: Center(child: Text('Checking...')),
        )
        );
flutter: upgrader.ITunesResults.version: RangeError (index): Invalid value: Valid value range is empty: 0
flutter: upgrader.ITunesResults.trackViewUrl: RangeError (index): Invalid value: Valid value range is empty: 0

ITunesSearchAPI Example and error

/// CHECK FOR IOS UPDATE
Future<void> checkForIOSUpdate() async {
  await Future.delayed(Duration.zero);
  final iTunes = ITunesSearchAPI();
  final resultsFuture = iTunes.lookupByBundleId('com.******.*****);
  resultsFuture.then((results) {
    print('results: $results');
  });

  /*
  UpgradeAlert();
  */
}

flutter: results: {resultCount: 0, results: []}

@larryaasen
Copy link
Owner

@NTMS2017 When you use the command line app, it will tell you the details of your bundle on the App Store. Can you run it and provide your results here? Here is an example:
$ dart itunes_lookup.dart bundleid=com.google.Maps
Also, is your app in the US App Store?

@larryaasen larryaasen added the need more information Further information is requested label Jan 19, 2020
@larryaasen larryaasen self-assigned this Jan 19, 2020
@NTMS2017
Copy link
Author

@larryaasen I got zsh: command not found: dart after running a command that you posted.

My .zshrc has only this 3 line as shown below. I didn't install dart, it came with flutter. And yes my App is In App Store but not sure if is the US App Store. When I publish my app in app store I configure only Turkey and Cyprus.

xport PATH="$PATH:/Users/myusername/flutter/bin"
export PATH="$PATH:/Users/myusername/.pub-cache⁩/bin"
export PATH="$PATH:/Users/myusername/flutter⁩/bin/cache/dart-sdk/"

@larryaasen
Copy link
Owner

@NTMS2017 Try:
/Users/myusername/flutter/bin/cache/dart-sdk/bin/dart itunes_lookup.dart bundleid=<your_bundle_id>

@NTMS2017
Copy link
Author

NTMS2017 commented Jan 20, 2020

Thanks, but I got error as shown below. My app is not inn US App Store. When I login to AppStoreConnect the link show as https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/14******20

How can I use package for my country App Store?

Error: Error when reading 'itunes_lookup.dart': No such file or directory

@larryaasen
Copy link
Owner

Using Terminal or another command line app, change directory to upgrader and run this:
/Users/myusername/flutter/bin/cache/dart-sdk/bin/dart bin/itunes_lookup.dart bundleid=<your_bundle_id>

@NTMS2017
Copy link
Author

NTMS2017 commented Jan 20, 2020

ok when I use this link https://itunes.apple.com**/tr/**lookup?bundleId=myappbundle it works and I get some json file but couldn't see the version. Any idea?

@larryaasen
Copy link
Owner

Can you provide the results here?

@NTMS2017
Copy link
Author

This /Users/myusername/flutter/bin/cache/dart-sdk/bin/dart bin/itunes_lookup.dart bundleid=<your_bundle_id> also gave me an error:

Error: Error when reading 'bin/itunes_lookup.dart': No such file or directory

@NTMS2017
Copy link
Author

Here is the json file: After format the json online I cann see down the json as:

  "version":"2.3.4+34",

{
   "resultCount":1,
   "results":[
      {
         "isGameCenterEnabled":false,
         "screenshotUrls":[
            "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/b7/ce/d1/b7ced172-c440-b334-e0f1-bc4db56c2ca4/mzl.qdnqtjds.jpg/392x696bb.jpg",
            "https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/05/a9/cd/05a9cd97-fee1-3a86-e434-25111dbbdc47/mzl.dtjpvvth.jpg/392x696bb.jpg",
            "https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/af/b6/63/afb663c8-22cd-bdf2-47c2-85e11365285e/mzl.knajtkat.jpg/392x696bb.jpg",
            "https://is1-ssl.mzstatic.com/image/thumb/Purple123/v4/b7/a8/51/b7a8511d-f053-43a4-2753-3062de015376/mzl.wthcskfy.jpg/392x696bb.jpg",
            "https://is1-ssl.mzstatic.com/image/thumb/Purple123/v4/10/22/37/102237da-301a-a16b-6f5a-b8efafde36bd/mzl.kossvopc.jpg/392x696bb.jpg",
            "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/62/c7/b9/62c7b97d-ff2c-51aa-ef8c-ceb40dd83ea4/mzl.usyxwccf.jpg/392x696bb.jpg",
            "https://is3-ssl.mzstatic.com/image/thumb/Purple113/v4/41/60/7f/41607f3c-8c36-d2c8-a6bf-7fa38225f9d3/mzl.yuthxpyq.jpg/392x696bb.jpg",
            "https://is4-ssl.mzstatic.com/image/thumb/Purple113/v4/e9/94/a1/e994a170-693d-0edf-d645-87caece93997/mzl.lnpxtiab.jpg/392x696bb.jpg",
            "https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/04/42/33/04423388-3c47-1396-7531-8b09aa6b2604/mzl.ogutwqeh.jpg/392x696bb.jpg",
            "https://is3-ssl.mzstatic.com/image/thumb/Purple113/v4/ae/d4/4b/aed44b5c-df26-80f5-acf5-e716df179b55/mzl.gmcmnfhf.jpg/392x696bb.jpg"
         ],
         "ipadScreenshotUrls":[
            "https://is2-ssl.mzstatic.com/image/thumb/Purple123/v4/22/f8/b1/22f8b164-5055-1fe7-780d-d2aaad8c5232/mzl.wivvayen.png/576x768bb.png",
            "https://is2-ssl.mzstatic.com/image/thumb/Purple123/v4/c9/04/fe/c904fe7f-e8ec-e3cd-fc00-c69a8fb78d46/mzl.stwvmuhn.png/576x768bb.png",
            "https://is1-ssl.mzstatic.com/image/thumb/Purple123/v4/a1/ea/f3/a1eaf378-c2b0-7326-86d3-c7f2c88a34e3/mzl.rcjswbgr.png/576x768bb.png",
            "https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/50/b5/fe/50b5fee2-cd99-b21f-172a-50be14df666d/mzl.dppqjjdu.png/576x768bb.png",
            "https://is2-ssl.mzstatic.com/image/thumb/Purple113/v4/9a/17/2a/9a172ac5-a1f4-f8d6-48af-d7f5fa74017f/mzl.fdbqkowy.png/576x768bb.png",
            "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/5b/5f/10/5b5f10de-ef60-3889-19e4-0c6ddcd88112/mzl.wkynkrpr.png/576x768bb.png",
            "https://is5-ssl.mzstatic.com/image/thumb/Purple123/v4/e6/dc/06/e6dc06b0-4fc6-eff1-b653-8822a23923e1/mzl.fbynavrm.png/576x768bb.png",
            "https://is2-ssl.mzstatic.com/image/thumb/Purple123/v4/51/be/4d/51be4d2a-33cc-b06d-29d4-148a7bf9d755/mzl.vntjgizi.png/576x768bb.png"
         ],
         "appletvScreenshotUrls":[

         ],
         "artworkUrl60":"https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/40/13/f5/4013f5ed-90e3-aefc-802d-ae038c9385d0/source/60x60bb.jpg",
         "artworkUrl512":"https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/40/13/f5/4013f5ed-90e3-aefc-802d-ae038c9385d0/source/512x512bb.jpg",
         "artworkUrl100":"https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/40/13/f5/4013f5ed-90e3-aefc-802d-ae038c9385d0/source/100x100bb.jpg",
         "artistViewUrl":"https://apps.apple.com/tr/developer/kibris-kapitalbank-ltd/id1458847765?uo=4",
         "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"
         ],
         "advisories":[

         ],
         "kind":"software",
         "features":[
            "iosUniversal"
         ],
         "trackCensoredName”:”***************”,
         "languageCodesISO2A":[
            "EN"
         ],
         "fileSizeBytes":"45254656",
         "sellerUrl":"https://www.youtube.com/watch?v=v09OoPqB2Bw",
         "contentAdvisoryRating":"4+",
         "averageUserRatingForCurrentVersion":5.0,
         "userRatingCountForCurrentVersion":1,
         "trackViewUrl":"https://apps.apple.com/tr/app/******************/id1460361220?uo=4",
         "trackContentRating":"4+",
         "trackId":1460361220,
         "trackName”:”******************”,
         "releaseDate":"2019-04-26T20:12:22Z",
         "currentVersionReleaseDate":"2019-12-19T17:25:25Z",
         "releaseNotes":"Güncelleme ******”,
         "isVppDeviceBasedLicensingEnabled":true,
         "primaryGenreName":"Finance",
         "genreIds":[
            "6015",
            "6000"
         ],
         "primaryGenreId":6015,
         "sellerName”:”***************”,
         "formattedPrice":"Free",
         "minimumOsVersion":"11.0",
         "currency":"TRY",
         "version":"2.3.4+34",
         "wrapperType":"software",
         "bundleId”:”c************”,
         "artistId":1458847765,
         "artistName”:”****”*************,
         "genres":[
            "Finance",
            "Business"
         ],
         "price":0.00,
         "description”:”*************.”,
         "averageUserRating":5.0,
         "userRatingCount":6
      }
   ]
}

@NTMS2017
Copy link
Author

Any news? Also is upgrader force my app to update from App Store?

@larryaasen
Copy link
Owner

I figured out the problem. This package does not support countries outside of the US very well. Since your app is in the TR country App Store, the response returned empty, so a new version was not found.

I was able to get the included example app to work with these few changes that you can make to get this package to work for you.

  1. Open the example workspace file in Xcode: upgrader/example/ios/Runner.xcworkspace
  2. In the Runner target General properties, change the Bundle Identifier to your bundle ID.
  3. Open the file: upgrader/lib/src/upgrader.dart and change the country on this line from US to TR:
    _countryCode ??= 'TR';
  4. Run the example Flutter app in upgrader/example/lib/main.dart in a Simulator.
  5. You will see the upgrade alert showing Version 2.3.4+34 is now available-you have 1.0. See my screenshot below.

Screen Shot 2020-01-21 at 10 41 22 PM

@NTMS2017
Copy link
Author

@larryaasen thank you very much, I will try today and post the result here.

It will be nice to add country parameters to upgrader/lib/src/upgrader.dart so all Flutter developer can use this plugin.

Open the file: upgrader/lib/src/upgrader.dart and change the country on this line from US to TR:
_countryCode ??= 'TR';

@NTMS2017
Copy link
Author

NTMS2017 commented Jan 22, 2020

💯 🥇 👍

It couldn't better than this one. Kind Thanks.

It didn't print as a json format. And because of my country code TR I have few more questions?

  • How can I grab the appStoreVersion?
  • How can I change the showDialog message? I add my language versions of messages in prompt: section but on top still appears the ' A new version of ****** is available! Version 2.3.4+34 is now available-you have 2.3.3.' I need to change this English line to my language.

Here is the result:

flutter: results: {resultCount: 0, results: []}
flutter: upgrader: build UpgradeAlert
flutter: upgrader: package info packageName: com.*********.*******
flutter: upgrader: package info version: 2.3.3
flutter: upgrader: appStoreVersion: 2.3.4+34
flutter: upgrader: installedVersion: 2.3.3
flutter: upgrader: isUpdateAvailable: true
flutter: upgrader: showDialog title: Update App?
flutter: upgrader: showDialog message: A new version of ********** is available! Version 2.3.4+34 is now available-you have 2.3.3.
flutter: upgrader: build UpgradeAlert
flutter: upgrader: button tapped: UPDATE NOW
flutter: upgrader: launching: https://apps.apple.com/tr/app/********/id*******?uo=4

@NTMS2017
Copy link
Author

NTMS2017 commented Jan 22, 2020

Ok, I hack (because no documentation about it :) ) Upgrader and check if update is available. In initState I call _checkForIOSUpdate() and and if update is available in build widget body I show the AlertDialog. If not not I let user to use current app.

I thank you for this great packages. Kind Thanks

/// CHECK FOR IOS UPDATE
  Future _checkForIOSUpdate() async {
    setState(() {
      _runUpdateLoading = true;
    });

    Upgrader().clearSavedSettings();
    Upgrader().debugDisplayAlways = false;
    Upgrader().debugDisplayOnce = false;
    await Upgrader().initialize();
    bool _isAvailable = Upgrader().isUpdateAvailable();

    await Future.delayed(Duration(milliseconds: 250));

    print('_isAvailable: $_isAvailable');

    if (_isAvailable == true) {
      setState(() {
        _checkUpdate = true;
        _runUpdateLoading = false;
      });
    } else {
      setState(() {
        _checkUpdate = false;
        _runUpdateLoading = false;
      });
    }
  }

@larryaasen
Copy link
Owner

I am sorry this package has not met all of your needs, but I will continue to improve it in the future. Thanks for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more information Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants