JavaScript SDK

Overview of the PDX CitySync Javascript SDK and methods available to developers for use in their apps.

Core Methods

The PDX CitySync JavaScript SDK gives you access to the following API calls:

  • CitySync.connnect - create connection to PDXCitySync and receive app and user data.
    Accepts an optional callback if your application depends on user or app data.
  • CitySync.resizeFrame - send a call to resize your app's iframe on PDX CitySync
  • CitySync.sendAlert - send an alert to PDX CitySync's alerts framework

CitySync.connect(callback)

Before your application can receive user data, you'll need to first initiate the connection using the CitySync.connect API call:

<script type="text/javascript">
    CitySync.connect(function(){
        // Proceed with your app
    });
</script>

CitySync.init will return 'success' on successful authentication, and two data objects will become available to your app: CitySync.user and CitySync.appdata:

CitySync.user - contains user's location and interests.

CitySync.user = {
    interests:["interest","interest"],
    location:{
      lat: num,
      long: num
    }

CitySync.appdata - contains the path to your application's full view on PDX CitySync and detail page in the app catalog:

CitySync.appdata ={
  fullurl:"path-to-full-view",
  catalogurl:"path-to-detail-page"
}

CitySync.resizeFrame(height)

You can call this method whenever you need to resize your apps' iframe on PDX CitySync:

<script type="text/javascript">
  CitySync.resizeFrame(document.body.scrollHeight);
</script>

CitySync.sentAlert(message)

You can use sendAlert to send a message to PDX CitySync's alert framework, which will be displayed on the user's homepage:

<script type="text/javascript">
  CitySync.sendAlert("This is an alert message");
</script>

Continue reading Sample App: Local Schools