CodePush: Where to find Deployment Key for Visual Studio project

11.4k views Asked by At

I'm trying on code push in my Visual studio project now. I done installing cordova plugin code push and able to see the instance with console.log(codePush).

Now I try to run codePush.checkForUpdate() and I notice that I need to fill in the Deployment Key in config.xml.

I read several articles about deployment key but all of them use the Ionic CLI to create the project and they can retrieve the deployment key in CLI. But I don't see any option in Visual Studio for that nor see any deployment key info anywhere.

Please advice on how to get the deployment key for my Visual Studio project in order to enable codePush.

3

There are 3 answers

1
Koo SengSeng On BEST ANSWER

After many hours of struggle, I found a solution on this. As a result, I actually need to follow EVERY single step as provided here, here and here. I really need to cross check between these 3 links to make things work.

Here is what I did:

1) In Visual Studio Package Manager Console, do this npm install -g code-push-cli. This will install the necessary for CodePush CLI

2) In the console, do code-push register. This will open a browser and register your account and associate with github or microsoft platform for code sync later on.

3) After successful registration, do code-push login. This will open up the browser and generate an access key for you. Suppose, a CLI will pop up and allow you to key in the access key for login. But in my case, the console hang. So I have to do code-push login --accessKey <accessKey> method to login.

4) After that, do code-push app add <app_name> to register the app. This will send info to code push server and allow your app to perform code push

5) Do code-push deployment add <app_name> "Staging" to enable the app for deployment to server

6) When adding for deployment is successful, do code-push deployment ls <app_name> -k to retrieve the Deployment Key for Staging and Production

I still need to trial-and-error for using the code in the application. But at least I'm manage to get the deployment key for now.

Hope it helps those who are using ionic with code push

1
Ben Butterworth On

It seems some parts of the documentation isn't keeping up with the CLI changes. If you've installed the appcenter-cli as per their App Center Guide, then you can use that.

  1. First, login, appcenter login
  2. You need an app, create one on https://appcenter.ms/apps or with appcenter apps create -d APP_NAME -o Android -p Cordova. Because the CLI is case sensitive, you're better off using that website.
  3. Set your current app to the app you want to deploy, appcenter apps set APP_NAME
  4. Then, you create a deployment for your currently selected app: appcenter codepush deployment add DEPLOYMENT_NAME
  5. Cordova specific: Then send it off to users, appcenter codepush release-cordova -a USERNAME/APP_NAME
    1. Bonus (for react native): appcenter codepush release-react -a USERNAME/APP_NAME -d DEPLOYMENT_NAME
0
Dylan Smith On

For anyone who finds their way here working with CodePush that's now a part of App Center, you may need to run this command:

appcenter codepush deployment list -k

or

appcenter codepush deployment list -k --app <ownerName>/<appName>

if you don't have your app name set up in an environment variable etc. More details here: https://learn.microsoft.com/en-us/appcenter/distribution/codepush/cordova