Skip to content

Instantly share code, notes, and snippets.

@wadewegner
Last active January 29, 2018 23:54
Show Gist options
  • Save wadewegner/449ccbfe94c21cd52cc9330488e69b30 to your computer and use it in GitHub Desktop.
Save wadewegner/449ccbfe94c21cd52cc9330488e69b30 to your computer and use it in GitHub Desktop.
Demo using the mobile SDK and Salesforce CLI and Scratch Orgs
export FORCE_SPINNER_DELAY=
export FORCE_SHOW_SPINNER=
# remove old force project
rm -rf force
# set the callback URL
callbackUrl="sfdx://success"
# create force project
project="$(sfdx force:project:create -n force)";
# open folder
cd force
# create a scratch org
org="$(sfdx force:org:create -s -f config/project-scratch-def.json)";
# Create a connected app
connectedApp="$(sfdx waw:connectedapp:create -c $callbackUrl -e wade.wegner@gmail.com -n mobile -l mobile -d mobile -s Api,Web,RefreshToken)";
consumerKey="$(echo ${connectedApp} | jq -r .oauthConfig.consumerKey)"
echo "Consumer Key: " $consumerKey
# generate a password
password="$(sfdx force:user:password:generate)"
# get values
display="$(sfdx force:org:display --json)"
result="$(echo ${display} | jq -r .result)"
password="$(echo ${result} | jq -r .password)"
username="$(echo ${result} | jq -r .username)"
instanceUrl="$(echo ${result} | jq -r .instanceUrl)"
# echo values
echo "Username: " $username
echo "Password: " $password
echo "Instance URL: " $instanceUrl
echo "Callback URL: " $callbackUrl
# return to root
cd ..
Prerequisites
1) Install the Mobile SDK plugin: sfdx plugins:install sfdx-mobilesdk-plugin
2) Install WAW's plugin: sfdx plugins:install sfdx-waw-plugin
3) Create a new directory: mkdir gartner && cd gartner
Salesforce DX
1) Create an SFDX project: sfdx force:project:create -n force && cd force
2) Create a scratch org: sfdx force:org:create -s -f config/project-scratch-def.json
3) Create a connected app (copy down consumer key & secret): sfdx waw:connectedapp:create -c sfdx://success -e wade.wegner@gmail.com -n mobile -l mobile -d mobile -s Api,Web,RefreshToken
4) Create a password for the default user: sfdx force:user:password:generate
5) Get the custom domain URL and username: sfdx force:org:display
Mobile SDK
1) Create a react native app: sfdx mobilesdk:reactnative:create --platform ios --appname demo1 --packagename com.wadewegner.demo1 --organization WadeWegner.com --outputdir app
2) Open Xcode and open project under /gartner/app/ios/demo1.xcworkspace
3) Update RemoteAccessConsumerKey and OAuthRedirectURI in AppDelegate.m
Run the app
1) Go to React Native app root (e.g. /gartner/app)
2) Start react: npm start
3) In Xcode, click Run
4) Click "Use Custom Domain"
5) Paste in the Instance Url
6) Use the username & password
Done!
@quintonwall
Copy link

Pro (iOS) dev native:

  1. Add SwiftlySalesforce cocoapod to Podfile
  2. Run pod install
  3. Open xcode workspace and configure SwiftlySalesforce
  4. Update app with a promise to fetch salesforce data.
  5. beer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment