Skip to content

Latest commit

 

History

History
152 lines (115 loc) · 5.92 KB

DEMO.md

File metadata and controls

152 lines (115 loc) · 5.92 KB

DEMO

This nativescript plugin contains an app that has to
be published at least to a closed release track for
testint in app purchases.

Product IDs list

Since the app stores do not provide a service to request all available products,
the product IDs must be provided by the implementor it self.
This app does request the product IDs remotely via http GET request.
The url to this remote service is defined platform specific files in folder ./demo/src/settings.

The result must be a JSON of type ProductIDListings
described in products.model.ts

Here an example JSON

    {
        "test_level_1": {
            "id": "test_level_1",
            "consumable": false,
            "description": "description is optional"
        },
        "test_moneybag_1": {
            "id": "test_moneybag_1",
            "consumable": true,
            "description": "description is optional"
        }
    }

Note:
This demo uses the remote JSON storage jsonblob.com to hold the product lists.
See also ./demo-resources/in-app-purchases-json/README.md

Build or run demo

First of all cd into src directory:

    $ cd src/

The demo app

Run

To run the angular demo with android

    $ npm run demo.android

To debug the angular demo with android

    $ npm run demo.android.debug

For IOS simply change android with ios like

    $ npm run demo.ios

Release build

Android

Create release build APK

    tns build android --release \
    --key-store-path <path> \
    --key-store-password <pass> \
    --key-store-alias <alias> \
    --key-store-alias-password <pass> \
    --copy-to <path>/app-id.apk

In case the app is too big Google Play Store requires to upload an Android App Bundle instead of an APK

Create release build Android App Bundle

    tns build android --release \
    --key-store-path <path> \
    --key-store-password <pass> \
    --key-store-alias <alias> \
    --key-store-alias-password <pass> \
    --aab \
    --copy-to <path>/app-id.aab
Version counter

You might execute this inside you project dir to automated counting up the version code

    node -e "\
    let a='app/App_Resources';try{a=(JSON.parse(require('fs').readFileSync('nsconfig.json'))||{}).appResourcesPath||''}catch(e){};\
    var aManifest=a+'/Android/src/main/AndroidManifest.xml';\
    var fs=require('fs');\
    var xml=fs.readFileSync(aManifest,'utf8');\
    var _xs;var _xv=xml;_xv=_xv.substring(_xs=_xv.indexOf('android:versionCode=\"')+'android:versionCode=\"'.length,_xv.indexOf('\"',_xs)).trim();\
    var newXML=xml.replace(new RegExp('(.*)(android:versionCode=\")([0-9]*)(\")(.*)','g'),'\$1\$2'+'__VERSION__'+'\$4\$5');\
    var version=Number.parseInt(_xv)+1;\
    newXML=newXML.replace('__VERSION__',version);\
    fs.writeFileSync(aManifest,newXML);\
    console.log(version);\
    "

here a one line as script for the package.json

    "bump-version-android" : "node -e \"let a='app\/App_Resources';try{a=(JSON.parse(require('fs').readFileSync('nsconfig.json'))||{}).appResourcesPath||''}catch(e){};var aManifest=a+'\/Android\/src\/main\/AndroidManifest.xml';var fs=require('fs');var xml=fs.readFileSync(aManifest,'utf8');var _xs;var _xv=xml;_xv=_xv.substring(_xs=_xv.indexOf('android:versionCode=\\\"')+'android:versionCode=\\\"'.length,_xv.indexOf('\\\"',_xs)).trim();var newXML=xml.replace(new RegExp('(.*)(android:versionCode=\\\")([0-9]*)(\\\")(.*)','g'),'\\$1\\$2'+'__VERSION__'+'\\$4\\$5');var version=Number.parseInt(_xv)+1;newXML=newXML.replace('__VERSION__',version);fs.writeFileSync(aManifest,newXML);console.log(version);\""

IOS

You might execute this inside you project dir to automated counting up the version code

    node -e "\
    let a='app/App_Resources';try{a=(JSON.parse(require('fs').readFileSync('nsconfig.json'))||{}).appResourcesPath||''}catch(e){};\
    var aManifest=a+'/iOS/Info.plist';\
    var fs=require('fs');\
    var xml=fs.readFileSync(aManifest,'utf8');\
    var _xs;var _xv=xml;_xv=_xv.substring(_xs=_xv.indexOf('CFBundleVersion</key>')+'CFBundleVersion</key>'.length,_xv.indexOf('</string>',_xs)).replace('<string>','').replace('</string>','').trim();\
    var newXML=xml.replace(new RegExp('(.*)(<key>CFBundleVersion</key>)([\n\r\t])*(<string>)(.*)(</string>)',''),'\$1\$2\$3\n\t\$4__VERSION__\$6');\
    var _xva=_xv.split('.');\
    _xva[_xva.length-1]=Number.parseInt(_xva[_xva.length-1])+1;\
    var version=_xva.join('.');\
    newXML=newXML.replace('__VERSION__',version);\
    fs.writeFileSync(aManifest,newXML);\
    console.log(version);"

here a one line as script for the package.json

    "bump-version-ios" : "node -e \"let a='app\/App_Resources';try{a=(JSON.parse(require('fs').readFileSync('nsconfig.json'))||{}).appResourcesPath||''}catch(e){};var aManifest=a+'\/iOS\/Info.plist';var fs=require('fs');var xml=fs.readFileSync(aManifest,'utf8');var _xs;var _xv=xml;_xv=_xv.substring(_xs=_xv.indexOf('CFBundleVersion<\/key>')+'CFBundleVersion<\/key>'.length,_xv.indexOf('<\/string>',_xs)).replace('<string>','').replace('<\/string>','').trim();var newXML=xml.replace(new RegExp('(.*)(<key>CFBundleVersion<\/key>)([\\n\\r\\t])*(<string>)(.*)(<\/string>)',''),'\\$1\\$2\\$3\\n\\t\\$4__VERSION__\\$6');var _xva=_xv.split('.');_xva[_xva.length-1]=Number.parseInt(_xva[_xva.length-1])+1;var version=_xva.join('.');newXML=newXML.replace('__VERSION__',version);fs.writeFileSync(aManifest,newXML);console.log(version);\""