SlideShare a Scribd company logo
iOS at Work:
                      Integrating iOS Apps with
                         Back End Systems
                    Tulsa Dev Lunch
                       February 13, 20
                                      1   3
                                                    Mat     llowaoydinaire)
                                                        t Ga a r
                                                           obile Develo per Extr
                                              (Fr eelance M


Wednesday, February 13, 13
h at  a bo  ut
                             W           d?
                               A n dr oi

Wednesday, February 13, 13
Android s
                                                      ucks.
                             (Espec ially for business.)




Wednesday, February 13, 13
Most Consistent API




           Consistent Hcxrdwcxre

                                   --


                   Best Securit.Y




   1=eel G-ood Kumb·,cx Pseudo Open
                     Source-ness
Wednesday, February 13, 13
aid, most of what I’m gonna say a bout iOS applies to Android too.
      That s                                                               Meh.

Wednesday, February 13, 13
Th ink m obile!
                             Th ink n ow!
Wednesday, February 13, 13
Ch aracteristi cs of Mobile
                               not a keyboard  /mouse paradigm
                                         small screen
             unreliable low bandwidth high latency network connection

                            ocessing power a nd local storage
                 limited pr
                                      limited battery life
                                  hostile work environment
                      untapped resources: camera(s), acceler
                                                            ometers,
                           GPS, phone, speaker, mic, LED flash

Wednesday, February 13, 13
Wednesday, February 13, 13
Mo bile w eb or die.

Wednesday, February 13, 13
Natrve (iOS, Android,
                                                 Blackberry, Windows
                                                 Phone) App Window


                                                                Flll~dwith a single
                Awesome Dashboard                            We.bVIeW widget loaded
                         "App"                                With your mobile web
                                                                     content.




                                    Awesome Dashboard
                                         "App"




Wednesday, February 13, 13
Wednesday, February 13, 13
When the web wo n’t do.
          Performance/Responsiveness/UX.
             Complex lo cal data store.
                      Ne twork optional.
            Hardware control.
                         Sophisticated UI.
           3D/a ccelerated   graphics.
Wednesday, February 13, 13
re ent erprise mobile
          How a
              ap ps diff erent?
                             Complex local data st
                                           res.    o
                   I ntegration wi th back office
                             systems.
Wednesday, February 13, 13
,..__---------~----~~



                   Mob.1le      Inte_gr~t:1on J>os &- J>on'ts
                                   ,
                             OV                        0
                              Cove-r -the Yet)                                             I
                                                                                            I
                                                                                            I
                                                                                            I
                                                                                            I
                                                                                            I
                                                               Crf ~oLA he>.ve -t:.o)       /
                                                                                        I
                                                                                        I
                                                                                        I
                                                                                        I
                                                                                        I
                                                                                        I
                                                                                        I
                                                                                        I

                                                  f>ov-ts B$Z> &-443                    I
                                                                                        I
                                                                                        I
                                                                                        I
Wednesday, February 13, 13
Protot_yp·,ccxrash
                              EVterpr·,se Arch.atecture
                  ""'
                -+l
                 -
                .a...
                 ~
                          •

        H       o
               (/)
                        (J
                        ;.J
                         <U
                                   H
                                   ~       LU""
                                             '      •
                                                        H
                                                        ~      LU""
                                                                 '    (J
                                                                        •
        :J     >l-...
               cS                  <(_     LU-tJ
                                                  (J
                                                        <(_    LU-tJ
               <Sw
               hZ.                 -:s      ~     (U    -:s    ~      (U
                                                                             sG.'-
        _g        ""'~             4-      h    '""     4-     h    '""
         cu(/)V)                   r-        '""~       r-       '""~
                                           r-~                 r-~
        3~~                        (/)                  (/)
                  ""Q_.            LU      LU<!.        LU     LU<!.
         _J (/)                    p!.     z~           p!.   z~
                                                               •
    .          ~h                           •
               l-
              I.                                                            D~t~
                                                                            Stov-e
                                         Bus·aness      D~t~
 Present~ t·aon                                                 Access
                                          Lo.9·ac


Wednesday, February 13, 13
-~

                             EVtev-pv-·,se Av-ch·,tectuv-e)(
           .-
           ...Q
             0
          ~



                                                                D~t~
                                                                Stov-e
                                               D~t~ Access




Wednesday, February 13, 13
D~t~
                                                  Stov-e
                              Present~ t·aon )
                             Bus·aness Lo.9·ac;
                             &- D~t~ Access
Wednesday, February 13, 13
"EVtev-pv-·ase" Av-ch.atectuv-e
                              <;tu·ack·,e Mob·,r,z.cxt·aoV t=·,x



                                                                     .-
                                                                     ...Q
                                                                      0
                                                                     ~
                                       D~t~
                                       Stov-e
   Present~ t·aon )
 Bus·aness Lo.9·ac;                                   '/ oLA' VeeO to
                                                                      •
 &- D~t~ Access                                           bLA.,0 -t'n S.
Wednesday, February 13, 13
Discl  aimer : I’m
  not   .NET  devel  oper,
 bu tIe   xper iment   ed a
     little in co llege.
Wednesday, February 13, 13
In Vis ual St udio...
     1.) Create     a Web Project
                    a new  Entity Model
      2.) Create
      3.) Reverse enginee    r Entity Model
                 from Database
           reate a   WCF Dat   a Service o
     4.) C                      odel Cl ass t
            Add y our En tity M
       5.)                          ration
                               decla .
                         class cess
           the S ervice      a ac
               onf igure dat
         6.) C
Wednesday, February 13, 13
[JSONPSupportBehavior]
    public class Service : DataService<YourEnterpriseEntities>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.SetEntitySetAccessRule("Locations", EntitySetRights.AllRead);
            config.SetEntitySetAccessRule("Customers", EntitySetRights.All);
            config.SetEntitySetAccessRule("SalesOrders", EntitySetRights.All);
            config.SetEntitySetAccessRule("Secrets", EntitySetRights.None);

                  //Set a reasonable paging site
                  config.SetEntitySetPageSize("*", 25);

                  config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
           }
    }




Source:
http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx
Wednesday, February 13, 13
http:LLyourhost.comLservice.svcLCustomers()

 http:LLyourhost.comLservice.svcLCustomers(34)


 http:LLyourhost.comLservice.svcLCustomers()?
 $filter=substringof('itactile',Name) or
 substringof('Galloway' ,ContactLastName)&
 $format=json


 http:LLyourhost.comLservice.svcLCustomers(34)?
 $expand=Sales0rders$format=json


Wednesday, February 13, 13
http:LLyourhost.comLservice.svcL?~format=json



  {
  "d"       •
            •   {
  "Enti tySets" : [
  "Batches", "Drawings", "DrawingTypes", "Elements", "ElernentAnswers",
  "ElernentAnswerPhotoes", "ElernentGroups", "Elernenticons",
  "ElernentQuestions", "ElernentRequirernents", "ElernentTypes",
  "LocationMetaDatas", "LocationMetaDataFields", "Locations",
  "PickListirnages", "Projects", "StoreAccesses", "sysdiagrarns",
  "TestTables", "tlkDivisions", "UpdElernents", "UpdElernentAnswers",
  "UpdElernentAnswerPhotoes", "UpdLocationMetaDatas", "Users"
  ]
  }
  }




Wednesday, February 13, 13
http://yourhost.com/service.svc/ElementTypes?Sfor.mat=json

 {
 "d" :     [
 {
 " metadata": {
 "uri": "http: //yourhost.com/service.svc / ElementTypes(1)", "type": "YourDataModel.ElementType"
 }, "elementTypeid": 1, "name": "POS 1&2 Camera", "elementGroupid": 1, "lastModified": "/Date(1340728631167)/",
 "active": true, "elementiconid" : 3 4, "Elements" : {
 "_deferred": {
 "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / Elements"
  }
  } , "ElementGroup": {
  "_deferred": {
  "uri": "http://yourhost.com/service.svc/ElementTypes(1)/ElementGroup"
  }
  } , "Elementicon" : {
  "_deferred": {
  "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / Elementicon"
  }
 }, "ElementRequirements": {
 "_deferred": {
 "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / ElementReguirements"
  }
 }, "DrawingTypes": {
 "_deferred": {
 "uri": "http: //yourhost.com/service.svc / ElementTypes(1) /DrawingTypes "
  }
 }, "ElementQuestions": {
 "_deferred": {
 "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / ElementOuestions"
  }
  }
  }'   {
 " metadata": {
 "uri": "http: //yourhost.com/service.svc / ElementTypes(2)", "type": "YourDataModel.ElementType"
 }, "elementTypeid": 2, "name": "POS 3&4 Camera", "elementGroupid": 1, "lastModified": "/Date(1340728631167)/",


Wednesday, February 13, 13
http://yourhost.com/service.svc/ElementTypes(l)?Sformat=json&
 Sexpand=ElementGroup
 {
 "d"   :   {
 " metadata" : {
 "uri": "http : //yourhost.com/service.svc/ElementTypes(1)", "type" : "QTSecurityModel . ElementType"
 }, "elementTypei d": 1, "name" : "POS 1&2 Camera", "elementGroupid" : 1 , "lastModif i ed" : "/Date( 1340728631167) /", "active":
 true, "elementiconi d" : 34, "Elements" : {
 "_ de f erred" : {
 "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/Elements"
  }
  } , "ElementGroup": {
  "_metadata": {
  "uri": "http://yourhost.com/service.svc/ElementGroups(1)", "type": "QTSecurityModel.ElementGroup"
  }, "elementGroupid": 1, " name": "Cameras", "sortOrder": 1, "lastModified": "/ Date(1340289282327)/", " active": true,
  "ElementTypes": {
  "_deferred": {
  "uri": "http://yourhost.com/service.svc/ElementGroups(1)/ElementTypes"
  }
  }
  } , "Element i con" : {
  "_ de f erred" : {
  "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/Element i con"
  }
  }, "ElementRequirements" : {
  "_ de f erred" : {
  "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/ElementReguirements"
  }
  } , "DrawingTypes" : {
  "_ de f erred" : {
  "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/DrawingTypes"
  }
  }, "ElementQuestions" : {
  "_ de f erred" : {
  "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/ElementOu estions"
  }
  }
  }
  }



Wednesday, February 13, 13
The M obile Dev
                     POV

Wednesday, February 13, 13
Reading Data
+(id) syncRequest: (NSString *) urlString error:(NSError **) error {

     NSLog(@"syncRequest: %@",urlString);

     urlString=[SyncHelper addJsonToUri:urlString]; // Adds ?$format=json to URL

     NSURL *url = [NSURL URLWithString:urlString];

     NSError *internalError = nil;

     NSURLResponse *response=nil;

     NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

     if (HTTP_USER!=nil && [HTTP_USER length]>0 && HTTP_PASSWORD!=nil && [HTTP_PASSWORD length]>0) {
         NSString *authStr = [NSString stringWithFormat:@"%@:%@",HTTP_USER,HTTP_PASSWORD];
         NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
         NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
         [request setValue:authValue forHTTPHeaderField:@"Authorization"];
     }


     NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&internalError];

     if (!internalError) {
         internalError=nil;

        NSDictionary *interimDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments
error:&internalError];

         if (internalError!=nil) {
             NSLog(@"Error parsing JSON from syncRequest: %@ ",[internalError debugDescription]);

              if (error!=nil) *error=internalError;
              return nil;
         }

        NSDictionary *errorDict = [interimDict objectForKey:@"error"];
        if (errorDict!=nil) {
            NSDictionary *messageDict = [errorDict objectForKey:@"message"];
            NSString *errorMessage = [messageDict objectForKey:@"value"];
            if (error!=nil) *error=[NSError errorWithDomain:ERROR_DOMAIN code:4000 localizedDescription:[NSString stringWithFormat:@"Error received from
server: %@",errorMessage]];
            return nil;
        }




Wednesday, February 13, 13
id retVal = [interimDict objectForKey:@"d"];
              if ([retVal isKindOfClass:[NSDictionary class]] && [((NSDictionary *)retVal) objectForKey:@"results"]!=nil) {
                  return [((NSDictionary *)retVal) objectForKey:@"results"];
              } else {
                  return retVal;
              }

          } else {
              NSLog(@"Error: unable to complete web request because -   %@",[internalError localizedDescription]);
              if (error!=nil) *error=internalError;
              return nil;
          }




                                    NSArray
      }




           If result is a list, an
               NSMutab   leDiction  ary’s is
            of
                      ret  urned.
                    Otherwise, an
          NSMutableDictionary
                                  is returned.
Wednesday, February 13, 13
Inserting New Data
  +(BOOL) insertEntity:(id) entity entityName:(NSString *)entityName error:(NSError **) error
  {
      NSString *urlString = [SyncHelper urlStringForEntity:entityName]; // Turns “EntityName” into “http://yourserver/service.svc/EntityName

       NSURL *url = [NSURL URLWithString:urlString];

       NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

       [request   setHTTPMethod:@"POST"];
       [request   addValue:@"Application/json" forHTTPHeaderField:@"content-type"];
       [request   addValue:@"Application/json" forHTTPHeaderField:@"accept"];
       [request   setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];

       if (HTTP_USER!=nil && [HTTP_USER length]>0 && HTTP_PASSWORD!=nil && [HTTP_PASSWORD length]>0) {
           NSString *authStr = [NSString stringWithFormat:@"%@:%@",HTTP_USER,HTTP_PASSWORD];
           NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
           NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
           [request setValue:authValue forHTTPHeaderField:@"Authorization"];
       }

       NSError *internalError = nil;

       NSData *payload = [NSJSONSerialization dataWithJSONObject:entity options:NSJSONWritingPrettyPrinted error:&internalError];

       if (internalError != nil) {
           if (error!=nil) *error = internalError;
           return NO;
       }

       [request setHTTPBody: payload];

       NSHTTPURLResponse *response = nil;
       internalError = nil;

       NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&internalError];

       if (internalError != nil) {
           if (error!=nil) *error = internalError;
           return NO;
       }

       NSString *responseStatus = [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]];

       if ([response statusCode]!=201) {
           if (error!=nil) *error = [NSError errorWithDomain:ERROR_DOMAIN code:100
                   localizedDescription:[NSString stringWithFormat:@"HTTP ERROR (%i) %@",[response statusCode],responseStatus]];
       }

       return [response statusCode]==201;

  }


Wednesday, February 13, 13
+(BOOL) updateEntity:(NSMutableDictionary *)entity forKeys:(NSArray *)keys error:(NSError **) error {

     NSDictionary *metadata = [entity valueForKey:@"__metadata"];
     if (metadata==nil) return NO;

     NSURL *url = [NSURL URLWithString:[metadata valueForKey:@"uri"]];
     NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

     [request
     [request
                setHTTPMethod:@"POST"];
                addValue:@"MERGE" forHTTPHeaderField:@"X-HTTP-Method"];
                                                                                                          Updating Data
     [request   addValue:@"Application/json" forHTTPHeaderField:@"content-type"];
     [request   addValue:@"Application/json" forHTTPHeaderField:@"accept"];
     [request   setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];

     if (HTTP_USER!=nil && [HTTP_USER length]>0 && HTTP_PASSWORD!=nil && [HTTP_PASSWORD length]>0) {
         NSString *authStr = [NSString stringWithFormat:@"%@:%@",HTTP_USER,HTTP_PASSWORD];
         NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
         NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
         [request setValue:authValue forHTTPHeaderField:@"Authorization"];
     }

     NSMutableDictionary *payloadDict = [NSMutableDictionary dictionaryWithCapacity:10];

     [payloadDict setValue:metadata forKey:@"__metadata"];
     for (NSString *key in keys) {
         [payloadDict setValue:[entity valueForKey:key] forKey:key];
     }

     NSError *internalError = nil;

     NSData *payload = [NSJSONSerialization dataWithJSONObject:payloadDict options:NSJSONWritingPrettyPrinted error:&internalError];

     if (internalError != nil) {
         if (error!=nil) *error = internalError;
         return NO;
     }

     [request setHTTPBody: payload];

     NSHTTPURLResponse *response = nil;
     internalError = nil;

     NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&internalError];

     if (internalError != nil) {
         if (error!=nil) *error = internalError;
         return NO;
     }

     NSString *responseStatus = [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]];

     if ([response statusCode]!=204) {
         if (error!=nil) *error = [NSError errorWithDomain:ERROR_DOMAIN code:5000
            localizedDescription:[NSString stringWithFormat:@"HTTP ERROR (%i) %@",[response statusCode],responseStatus]];
     }

     return [response statusCode]==204;
 }

Wednesday, February 13, 13
What to Do With an NSMutableDictionary?
        1.) Parse into proper objects
       2.) Create a wrapper object that
    stores NSMutableDictionary internally
     3.) Use Objective-C Categories to add
   field-like methods to NSMutableDictionary
                    But don’t just
       [object objectForKey: @“propertyName“]
Wednesday, February 13, 13
//
         //   NSMutableDictionary+Customer.m
         //   Yale Cleaners
         //
         //   Created by Matt Galloway on 8/31/12.
         //   Copyright (c) 2012 Architactile LLC. All rights reserved.
         //

         #import "NSMutableDictionary+Customer.h"

         @implementation NSMutableDictionary (Customer)

         #pragma mark - Customer Custom Getters

         -(NSString *) mobileNumber {




                                                                                      ple
             return [self filteredObjectForKey:@"Mobile_no"];
         }




                                                                                      am
         -(NSString *) sendEmail {
             return [self filteredObjectForKey:@"SendEmail"];
         }




                                                                                    Ex
         -(NSString *) sendReceipt {
             return [self filteredObjectForKey:@"SendReceipt"];
         }




                                                                                 ry
         -(NSString *) sendText {
             return [self filteredObjectForKey:@"SendText"];
         }




                                                                            ego
         -(NSString *) username {
             return [self filteredObjectForKey:@"User_Name"];
         }




                                                                             t
         -(NSString *) uri {
             return [self filteredObjectForKey:@"uri"];



                                                                          Ca
         }

         -(NSString *) address {
             return [self filteredObjectForKey:@"address"];

         -(NSString *) area {
             return [self filteredObjectForKey:@"area"];
         }

         -(NSString *) charge {
             return [self filteredObjectForKey:@"charge"];
         }

         -(NSString *) city {
             return [self filteredObjectForKey:@"city"];
         }
         .
         .
         .


Wednesday, February 13, 13
Use  HTT  PS +
             Au then tica tion
             (at a  mini mum)
Wednesday, February 13, 13
Loca l Data Store?

                              M eet SQ Lite &
                                 Cor eData

Wednesday, February 13, 13
ata is  one of  iOS’s
      CoreD
     greate st adv  antag  es over
             d for b usiness apps.
      Androi

Wednesday, February 13, 13
PrtmaryK _y _--1
            _e;_                                       • Anr butt~
                                                       hc: dlypc:                                                Louuonvet.lO.lt.l-,
                                                                                                                                          -
                                                                                                                                                                     C          Locat o n _----,~
                                                                                                                                                                                    _o _
                                                                                                                                                                                       _
                                                       JSOnW~t~Od i fied                                        Annb~o~tcs                                           1 Auro butes
                                                                                                                                                                     9
                                                       loatoorMet~DJ.tJfield ld                               jsonlilstY.od I fled                                    OJddrusl
                                                       ,~e                                                    ocatton~ctOJDiltald                                     .lddreu2
                                                       pockl stCho ces                                        vo~lu tBool                                             City
                                                       required                                               v.llu eno~t                                             folde r' arne
                                                       • Rclattons hips                                     VJ.Iuelnt                                                 htghCr. mc:Locat.on
                                                                                                                                                                      J S.onuu~od o ticd
                                                       location~c:tt~Oata         <                         valueText
                                                                                                                                      -
                                                                                                               Rc ta11onsh1ps                                         loutoOf'lld
                                                                                                           !ocatton                                                   loutlonN u mber
                                                                                                                                              .;
            Pr OJeCt                                                                                                                                                  l'ame
     • Attll bU IC!S                                                                                                                                                  state
    folderNam e                                                                                                                                                       ~urveyCiodT me
    j sonl.ast'li~ocM1ed                                                                                                                                              surveyor
     name:                                                                                                                                                            sutleySct'leduled-IIM
     proJectld
    syn<Corn !)lete
       Re ~l i O nships
    draw-ng-ypes
    elementRe qul rements
                                                                                                                                                                      :~:~::~:d~~
                                                                                                                                                                      syt'I(Complete
                                                                                                                                                                      2op
                                                                                                                                                                                                        cotNple-Le
                                                                                                                                                                                                              I   J '        ~
                            fc::                                                                                                                                        Re :lto hlps
                                                                                                                                                                              ons
                                                                                                                                                                    >dto'lwings                 Elemc:ntRc:qu rc:rrc:f'll


                            1                                                              0r.Jwingiy____1
                                                                                                       JX
                                                                                                                            D•aw r.g
                                                                                                                   • Attribute~     ·--..-j~----+ locattonl'etaOata
                                                                                                                                         ~
                                                                                                                                                                                   ::__j
                                                                                                                                                                      e eme t~tRequi remc:nu     Anro    butes
                                                                                                                                                                                               e ementRequirementld
                                                                                       Attributes
                                                                                    dr.w,, ngTypeld
                                                                                                          1---------
                                                                                                                  drolw n!lld
                                                                                                                  fa en~rne
                                                                                                                                                            project                           JSOt'll...lStMOCifled
                                                                                                                                                                                               m.lXAllcw.ed
                                                                                    JSO nl...lstMOOif1ed                                                                                       m nRc:qu•rcd
                                                                                    name                          heo tgh                                                                        Relauonsho    ps
                                                                                       Re atton~h ps              JSOf'll.astMod•f1ed               , . - - - - + - - - - - - - - - --1-- ,..> drav. n!jType
                                                                                    dril'Wi ngs            A::llamc:                       i---1-~---+----------+--+~c: cmc:ntTypc

                                                          OementTyoe
                                                                                    c:o
                                                                                  --:
                                                                                      c:mc:ntRcquirc:mcnts
                                                                                    c c:mentType5
                                                                            !---t-~PI'OJ  ects _ _ _ ___,.J
                                                                                                                  scale
                                                                                                                  wlctth
                                                                                                                     Re ·" •onship~
                                                                                                                  d t.lWlngTypt
                                                                                                                                           1,..:::::1
                                                                                                                                           l ===------:!-------------lL...--~~~ocatoon
                                                                                                                                           :=
                                                                                                                                                                                             ~
                                                                                                                                                                                             "      d         ----'

                       E ementCroup
                  • Ann b"tc:s
                  elementGroupld
                                                  9 Annblltes
                                                  c:lememTypeld
                                                  ,conl tlename                                                                       eemenu          _
                                                                                                                                                          1_
                                                                                                                                                          ,                                         ~ t.~ ~                 cc
                                                                                                                                                                                                    l1.J
                  JsonLut'-1oct'lc:d             Jsonl..ut'Aocif,c:d
                  n;amc:
                  sortOrde r
                     Rel.'lt on·"s~"'c;===i
                                 " h t ps
                                                  narrc:
                                                      Rc: o'!t onhops
                                                  drilv.ongTypu                                                                             Element                                                             ess
                                                                                                                                                                                                         er w h
                                          /'.,.» elementCroup                                                                       AUt ib'->ttS
                                                                                                                                dra~o, ng(()Q(dX
                                                  c:lementQ..estlons
                                                  c:lementRequ lremen ts
                                                                                                                                ~;::·~~;=~:n                                                        V       ·,t.
                                                                                                                                                                                                      lm0 t.
                                                  c:lc:mc:nts
                                                                                                                                elementld

                                                  ~
                                                                                                                                clcmentll.umber
                                                                                                                                jsonl..ut'-1oditied
                                                   Eltmc:ntQue stlon
                                                                                                                                                                                                    ~
                                                 Attrobutes
                                              c: c:mc:ntQI.esbonld
                                                                                ~~
                                                                                                                                n.1me
                                                                                                                                'f Relat o n Sh pS
                                                                                                                                         O
                                                                                                                                                                                                             s
                                                                                                                                                                                                                            no
                                              nelpPnotofoename         !-------c:iementAnswc:rs
                                              help-tltt
                                               nchesMax



                                                                                                                                                                                         Code ~nd
                                               nches4ln
                                             json~tlod • tied                                                                          E c:mentAnswc:r     0 emc ntA.11s"'..: rPhoto
                                              pnoto.AI owNOt e~




                                                                                                                                                                            J
                                                                                                                                     Auro butes              Aur iba.tes
                                              :>hotoM.1xCount                                                                    OJnswc: rlnt              crc;atcdOn
                                              ohotoM nCount
                                              photoRc:qu rel'l.otcs
                                              p cl(L siC no cc:s
                                              quest Of'ITtxt
                                                                                                                                 .'lnswerText
                                                                                                                                 created On
                                                                                                                                 e emen!An~"erld
                                                                                                                                                           etementAnswerPhotold
                                                                                                                                                           gpsUto  tude
                                                                                                                                                           gpslottgltude
                                                                                                                                                                                                                             no
                                                                                                                                                                                                        SQL•
                                                                                                                                 gpslatttudc:              t'ludong
                                              quest on- 'fpe                                                                     gpslong tude              jsonLOJst'Aodoficd
                                              required                                                                           jsonLmVoct o      foed     .'lnMod fied
                                              sortOrdc:r                                                                         IJ.stl'-'od ned          ~otor den~e
                                              tc:xtMaxleng th                                                                        Re ilto ons"'lps      photoNotts
                                                 Rc: ilto
                                                        oqhips                                                                   e ement
                                              : :::~~~;~;:rs           "< _-------------------,fmentAn~"-C!rPhotos
                                                                        ;                                                                                 +u
Wednesday, February 13, 13
To Re  cap...
        A ndroid  sucks.
  Mobilize your web assets.
            he mob ile web first.
Con sider t
      Avoid SQL & SOAP.
    Use RESTful APIs.
Co reData i  s way w   orth it.
Wednesday, February 13, 13
Mat     llowaoydinaire)
                                        t Ga a r
                                           o bile Develo per Extr
                              (Fre elance M

                             matt@architactile.c
                                                                    om
                                  918 -808- 3072

Wednesday, February 13, 13

More Related Content

More from Matt Galloway

Tulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp TulsaTulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp Tulsa
Matt Galloway
 
How to Hire A Developer
How to Hire A DeveloperHow to Hire A Developer
How to Hire A Developer
Matt Galloway
 
Tulsa Small Business Resources
Tulsa Small Business ResourcesTulsa Small Business Resources
Tulsa Small Business Resources
Matt Galloway
 
Oklahoma Tweets
Oklahoma TweetsOklahoma Tweets
Oklahoma Tweets
Matt Galloway
 
Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009
Matt Galloway
 
Tulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & RecommendationsTulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & Recommendations
Matt Galloway
 

More from Matt Galloway (6)

Tulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp TulsaTulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp Tulsa
 
How to Hire A Developer
How to Hire A DeveloperHow to Hire A Developer
How to Hire A Developer
 
Tulsa Small Business Resources
Tulsa Small Business ResourcesTulsa Small Business Resources
Tulsa Small Business Resources
 
Oklahoma Tweets
Oklahoma TweetsOklahoma Tweets
Oklahoma Tweets
 
Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009
 
Tulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & RecommendationsTulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & Recommendations
 

Recently uploaded

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 

Recently uploaded (20)

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 

Tulsa Dev Lunch iOS at Work

  • 1. iOS at Work: Integrating iOS Apps with Back End Systems Tulsa Dev Lunch February 13, 20 1 3 Mat llowaoydinaire) t Ga a r obile Develo per Extr (Fr eelance M Wednesday, February 13, 13
  • 2. h at a bo ut W d? A n dr oi Wednesday, February 13, 13
  • 3. Android s ucks. (Espec ially for business.) Wednesday, February 13, 13
  • 4. Most Consistent API Consistent Hcxrdwcxre -- Best Securit.Y 1=eel G-ood Kumb·,cx Pseudo Open Source-ness Wednesday, February 13, 13
  • 5. aid, most of what I’m gonna say a bout iOS applies to Android too. That s Meh. Wednesday, February 13, 13
  • 6. Th ink m obile! Th ink n ow! Wednesday, February 13, 13
  • 7. Ch aracteristi cs of Mobile not a keyboard /mouse paradigm small screen unreliable low bandwidth high latency network connection ocessing power a nd local storage limited pr limited battery life hostile work environment untapped resources: camera(s), acceler ometers, GPS, phone, speaker, mic, LED flash Wednesday, February 13, 13
  • 9. Mo bile w eb or die. Wednesday, February 13, 13
  • 10. Natrve (iOS, Android, Blackberry, Windows Phone) App Window Flll~dwith a single Awesome Dashboard We.bVIeW widget loaded "App" With your mobile web content. Awesome Dashboard "App" Wednesday, February 13, 13
  • 12. When the web wo n’t do. Performance/Responsiveness/UX. Complex lo cal data store. Ne twork optional. Hardware control. Sophisticated UI. 3D/a ccelerated graphics. Wednesday, February 13, 13
  • 13. re ent erprise mobile How a ap ps diff erent? Complex local data st res. o I ntegration wi th back office systems. Wednesday, February 13, 13
  • 14. ,..__---------~----~~ Mob.1le Inte_gr~t:1on J>os &- J>on'ts , OV 0 Cove-r -the Yet) I I I I I I Crf ~oLA he>.ve -t:.o) / I I I I I I I I f>ov-ts B$Z> &-443 I I I I Wednesday, February 13, 13
  • 15. Protot_yp·,ccxrash EVterpr·,se Arch.atecture ""' -+l - .a... ~ • H o (/) (J ;.J <U H ~ LU"" ' • H ~ LU"" ' (J • :J >l-... cS <(_ LU-tJ (J <(_ LU-tJ <Sw hZ. -:s ~ (U -:s ~ (U sG.'- _g ""'~ 4- h '"" 4- h '"" cu(/)V) r- '""~ r- '""~ r-~ r-~ 3~~ (/) (/) ""Q_. LU LU<!. LU LU<!. _J (/) p!. z~ p!. z~ • . ~h • l- I. D~t~ Stov-e Bus·aness D~t~ Present~ t·aon Access Lo.9·ac Wednesday, February 13, 13
  • 16. -~ EVtev-pv-·,se Av-ch·,tectuv-e)( .- ...Q 0 ~ D~t~ Stov-e D~t~ Access Wednesday, February 13, 13
  • 17. D~t~ Stov-e Present~ t·aon ) Bus·aness Lo.9·ac; &- D~t~ Access Wednesday, February 13, 13
  • 18. "EVtev-pv-·ase" Av-ch.atectuv-e <;tu·ack·,e Mob·,r,z.cxt·aoV t=·,x .- ...Q 0 ~ D~t~ Stov-e Present~ t·aon ) Bus·aness Lo.9·ac; '/ oLA' VeeO to • &- D~t~ Access bLA.,0 -t'n S. Wednesday, February 13, 13
  • 19. Discl aimer : I’m not .NET devel oper, bu tIe xper iment ed a little in co llege. Wednesday, February 13, 13
  • 20. In Vis ual St udio... 1.) Create a Web Project a new Entity Model 2.) Create 3.) Reverse enginee r Entity Model from Database reate a WCF Dat a Service o 4.) C odel Cl ass t Add y our En tity M 5.) ration decla . class cess the S ervice a ac onf igure dat 6.) C Wednesday, February 13, 13
  • 21. [JSONPSupportBehavior] public class Service : DataService<YourEnterpriseEntities> { // This method is called only once to initialize service-wide policies. public static void InitializeService(DataServiceConfiguration config) { // config.SetEntitySetAccessRule("*", EntitySetRights.AllRead); config.SetEntitySetAccessRule("Locations", EntitySetRights.AllRead); config.SetEntitySetAccessRule("Customers", EntitySetRights.All); config.SetEntitySetAccessRule("SalesOrders", EntitySetRights.All); config.SetEntitySetAccessRule("Secrets", EntitySetRights.None); //Set a reasonable paging site config.SetEntitySetPageSize("*", 25); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } } Source: http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx Wednesday, February 13, 13
  • 22. http:LLyourhost.comLservice.svcLCustomers() http:LLyourhost.comLservice.svcLCustomers(34) http:LLyourhost.comLservice.svcLCustomers()? $filter=substringof('itactile',Name) or substringof('Galloway' ,ContactLastName)& $format=json http:LLyourhost.comLservice.svcLCustomers(34)? $expand=Sales0rders$format=json Wednesday, February 13, 13
  • 23. http:LLyourhost.comLservice.svcL?~format=json { "d" • • { "Enti tySets" : [ "Batches", "Drawings", "DrawingTypes", "Elements", "ElernentAnswers", "ElernentAnswerPhotoes", "ElernentGroups", "Elernenticons", "ElernentQuestions", "ElernentRequirernents", "ElernentTypes", "LocationMetaDatas", "LocationMetaDataFields", "Locations", "PickListirnages", "Projects", "StoreAccesses", "sysdiagrarns", "TestTables", "tlkDivisions", "UpdElernents", "UpdElernentAnswers", "UpdElernentAnswerPhotoes", "UpdLocationMetaDatas", "Users" ] } } Wednesday, February 13, 13
  • 24. http://yourhost.com/service.svc/ElementTypes?Sfor.mat=json { "d" : [ { " metadata": { "uri": "http: //yourhost.com/service.svc / ElementTypes(1)", "type": "YourDataModel.ElementType" }, "elementTypeid": 1, "name": "POS 1&2 Camera", "elementGroupid": 1, "lastModified": "/Date(1340728631167)/", "active": true, "elementiconid" : 3 4, "Elements" : { "_deferred": { "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / Elements" } } , "ElementGroup": { "_deferred": { "uri": "http://yourhost.com/service.svc/ElementTypes(1)/ElementGroup" } } , "Elementicon" : { "_deferred": { "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / Elementicon" } }, "ElementRequirements": { "_deferred": { "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / ElementReguirements" } }, "DrawingTypes": { "_deferred": { "uri": "http: //yourhost.com/service.svc / ElementTypes(1) /DrawingTypes " } }, "ElementQuestions": { "_deferred": { "uri": "http: //yourhost.com/service.svc / ElementTypes(1) / ElementOuestions" } } }' { " metadata": { "uri": "http: //yourhost.com/service.svc / ElementTypes(2)", "type": "YourDataModel.ElementType" }, "elementTypeid": 2, "name": "POS 3&4 Camera", "elementGroupid": 1, "lastModified": "/Date(1340728631167)/", Wednesday, February 13, 13
  • 25. http://yourhost.com/service.svc/ElementTypes(l)?Sformat=json& Sexpand=ElementGroup { "d" : { " metadata" : { "uri": "http : //yourhost.com/service.svc/ElementTypes(1)", "type" : "QTSecurityModel . ElementType" }, "elementTypei d": 1, "name" : "POS 1&2 Camera", "elementGroupid" : 1 , "lastModif i ed" : "/Date( 1340728631167) /", "active": true, "elementiconi d" : 34, "Elements" : { "_ de f erred" : { "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/Elements" } } , "ElementGroup": { "_metadata": { "uri": "http://yourhost.com/service.svc/ElementGroups(1)", "type": "QTSecurityModel.ElementGroup" }, "elementGroupid": 1, " name": "Cameras", "sortOrder": 1, "lastModified": "/ Date(1340289282327)/", " active": true, "ElementTypes": { "_deferred": { "uri": "http://yourhost.com/service.svc/ElementGroups(1)/ElementTypes" } } } , "Element i con" : { "_ de f erred" : { "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/Element i con" } }, "ElementRequirements" : { "_ de f erred" : { "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/ElementReguirements" } } , "DrawingTypes" : { "_ de f erred" : { "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/DrawingTypes" } }, "ElementQuestions" : { "_ de f erred" : { "uri": "http : //yourhost.com/service.svc/ElementTypes(1)/ElementOu estions" } } } } Wednesday, February 13, 13
  • 26. The M obile Dev POV Wednesday, February 13, 13
  • 27. Reading Data +(id) syncRequest: (NSString *) urlString error:(NSError **) error { NSLog(@"syncRequest: %@",urlString); urlString=[SyncHelper addJsonToUri:urlString]; // Adds ?$format=json to URL NSURL *url = [NSURL URLWithString:urlString]; NSError *internalError = nil; NSURLResponse *response=nil; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; if (HTTP_USER!=nil && [HTTP_USER length]>0 && HTTP_PASSWORD!=nil && [HTTP_PASSWORD length]>0) { NSString *authStr = [NSString stringWithFormat:@"%@:%@",HTTP_USER,HTTP_PASSWORD]; NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]]; [request setValue:authValue forHTTPHeaderField:@"Authorization"]; } NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&internalError]; if (!internalError) { internalError=nil; NSDictionary *interimDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments error:&internalError]; if (internalError!=nil) { NSLog(@"Error parsing JSON from syncRequest: %@ ",[internalError debugDescription]); if (error!=nil) *error=internalError; return nil; } NSDictionary *errorDict = [interimDict objectForKey:@"error"]; if (errorDict!=nil) { NSDictionary *messageDict = [errorDict objectForKey:@"message"]; NSString *errorMessage = [messageDict objectForKey:@"value"]; if (error!=nil) *error=[NSError errorWithDomain:ERROR_DOMAIN code:4000 localizedDescription:[NSString stringWithFormat:@"Error received from server: %@",errorMessage]]; return nil; } Wednesday, February 13, 13
  • 28. id retVal = [interimDict objectForKey:@"d"]; if ([retVal isKindOfClass:[NSDictionary class]] && [((NSDictionary *)retVal) objectForKey:@"results"]!=nil) { return [((NSDictionary *)retVal) objectForKey:@"results"]; } else { return retVal; } } else { NSLog(@"Error: unable to complete web request because - %@",[internalError localizedDescription]); if (error!=nil) *error=internalError; return nil; } NSArray } If result is a list, an NSMutab leDiction ary’s is of ret urned. Otherwise, an NSMutableDictionary is returned. Wednesday, February 13, 13
  • 29. Inserting New Data +(BOOL) insertEntity:(id) entity entityName:(NSString *)entityName error:(NSError **) error { NSString *urlString = [SyncHelper urlStringForEntity:entityName]; // Turns “EntityName” into “http://yourserver/service.svc/EntityName NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request addValue:@"Application/json" forHTTPHeaderField:@"content-type"]; [request addValue:@"Application/json" forHTTPHeaderField:@"accept"]; [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; if (HTTP_USER!=nil && [HTTP_USER length]>0 && HTTP_PASSWORD!=nil && [HTTP_PASSWORD length]>0) { NSString *authStr = [NSString stringWithFormat:@"%@:%@",HTTP_USER,HTTP_PASSWORD]; NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]]; [request setValue:authValue forHTTPHeaderField:@"Authorization"]; } NSError *internalError = nil; NSData *payload = [NSJSONSerialization dataWithJSONObject:entity options:NSJSONWritingPrettyPrinted error:&internalError]; if (internalError != nil) { if (error!=nil) *error = internalError; return NO; } [request setHTTPBody: payload]; NSHTTPURLResponse *response = nil; internalError = nil; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&internalError]; if (internalError != nil) { if (error!=nil) *error = internalError; return NO; } NSString *responseStatus = [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]]; if ([response statusCode]!=201) { if (error!=nil) *error = [NSError errorWithDomain:ERROR_DOMAIN code:100 localizedDescription:[NSString stringWithFormat:@"HTTP ERROR (%i) %@",[response statusCode],responseStatus]]; } return [response statusCode]==201; } Wednesday, February 13, 13
  • 30. +(BOOL) updateEntity:(NSMutableDictionary *)entity forKeys:(NSArray *)keys error:(NSError **) error { NSDictionary *metadata = [entity valueForKey:@"__metadata"]; if (metadata==nil) return NO; NSURL *url = [NSURL URLWithString:[metadata valueForKey:@"uri"]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request [request setHTTPMethod:@"POST"]; addValue:@"MERGE" forHTTPHeaderField:@"X-HTTP-Method"]; Updating Data [request addValue:@"Application/json" forHTTPHeaderField:@"content-type"]; [request addValue:@"Application/json" forHTTPHeaderField:@"accept"]; [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; if (HTTP_USER!=nil && [HTTP_USER length]>0 && HTTP_PASSWORD!=nil && [HTTP_PASSWORD length]>0) { NSString *authStr = [NSString stringWithFormat:@"%@:%@",HTTP_USER,HTTP_PASSWORD]; NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]]; [request setValue:authValue forHTTPHeaderField:@"Authorization"]; } NSMutableDictionary *payloadDict = [NSMutableDictionary dictionaryWithCapacity:10]; [payloadDict setValue:metadata forKey:@"__metadata"]; for (NSString *key in keys) { [payloadDict setValue:[entity valueForKey:key] forKey:key]; } NSError *internalError = nil; NSData *payload = [NSJSONSerialization dataWithJSONObject:payloadDict options:NSJSONWritingPrettyPrinted error:&internalError]; if (internalError != nil) { if (error!=nil) *error = internalError; return NO; } [request setHTTPBody: payload]; NSHTTPURLResponse *response = nil; internalError = nil; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&internalError]; if (internalError != nil) { if (error!=nil) *error = internalError; return NO; } NSString *responseStatus = [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]]; if ([response statusCode]!=204) { if (error!=nil) *error = [NSError errorWithDomain:ERROR_DOMAIN code:5000 localizedDescription:[NSString stringWithFormat:@"HTTP ERROR (%i) %@",[response statusCode],responseStatus]]; } return [response statusCode]==204; } Wednesday, February 13, 13
  • 31. What to Do With an NSMutableDictionary? 1.) Parse into proper objects 2.) Create a wrapper object that stores NSMutableDictionary internally 3.) Use Objective-C Categories to add field-like methods to NSMutableDictionary But don’t just [object objectForKey: @“propertyName“] Wednesday, February 13, 13
  • 32. // // NSMutableDictionary+Customer.m // Yale Cleaners // // Created by Matt Galloway on 8/31/12. // Copyright (c) 2012 Architactile LLC. All rights reserved. // #import "NSMutableDictionary+Customer.h" @implementation NSMutableDictionary (Customer) #pragma mark - Customer Custom Getters -(NSString *) mobileNumber { ple return [self filteredObjectForKey:@"Mobile_no"]; } am -(NSString *) sendEmail { return [self filteredObjectForKey:@"SendEmail"]; } Ex -(NSString *) sendReceipt { return [self filteredObjectForKey:@"SendReceipt"]; } ry -(NSString *) sendText { return [self filteredObjectForKey:@"SendText"]; } ego -(NSString *) username { return [self filteredObjectForKey:@"User_Name"]; } t -(NSString *) uri { return [self filteredObjectForKey:@"uri"]; Ca } -(NSString *) address { return [self filteredObjectForKey:@"address"]; -(NSString *) area { return [self filteredObjectForKey:@"area"]; } -(NSString *) charge { return [self filteredObjectForKey:@"charge"]; } -(NSString *) city { return [self filteredObjectForKey:@"city"]; } . . . Wednesday, February 13, 13
  • 33. Use HTT PS + Au then tica tion (at a mini mum) Wednesday, February 13, 13
  • 34. Loca l Data Store? M eet SQ Lite & Cor eData Wednesday, February 13, 13
  • 35. ata is one of iOS’s CoreD greate st adv antag es over d for b usiness apps. Androi Wednesday, February 13, 13
  • 36. PrtmaryK _y _--1 _e;_ • Anr butt~ hc: dlypc: Louuonvet.lO.lt.l-, - C Locat o n _----,~ _o _ _ JSOnW~t~Od i fied Annb~o~tcs 1 Auro butes 9 loatoorMet~DJ.tJfield ld jsonlilstY.od I fled OJddrusl ,~e ocatton~ctOJDiltald .lddreu2 pockl stCho ces vo~lu tBool City required v.llu eno~t folde r' arne • Rclattons hips VJ.Iuelnt htghCr. mc:Locat.on J S.onuu~od o ticd location~c:tt~Oata < valueText - Rc ta11onsh1ps loutoOf'lld !ocatton loutlonN u mber .; Pr OJeCt l'ame • Attll bU IC!S state folderNam e ~urveyCiodT me j sonl.ast'li~ocM1ed surveyor name: sutleySct'leduled-IIM proJectld syn<Corn !)lete Re ~l i O nships draw-ng-ypes elementRe qul rements :~:~::~:d~~ syt'I(Complete 2op cotNple-Le I J ' ~ fc:: Re :lto hlps ons >dto'lwings Elemc:ntRc:qu rc:rrc:f'll 1 0r.Jwingiy____1 JX D•aw r.g • Attribute~ ·--..-j~----+ locattonl'etaOata ~ ::__j e eme t~tRequi remc:nu Anro butes e ementRequirementld Attributes dr.w,, ngTypeld 1--------- drolw n!lld fa en~rne project JSOt'll...lStMOCifled m.lXAllcw.ed JSO nl...lstMOOif1ed m nRc:qu•rcd name heo tgh Relauonsho ps Re atton~h ps JSOf'll.astMod•f1ed , . - - - - + - - - - - - - - - --1-- ,..> drav. n!jType dril'Wi ngs A::llamc: i---1-~---+----------+--+~c: cmc:ntTypc OementTyoe c:o --: c:mc:ntRcquirc:mcnts c c:mentType5 !---t-~PI'OJ ects _ _ _ ___,.J scale wlctth Re ·" •onship~ d t.lWlngTypt 1,..:::::1 l ===------:!-------------lL...--~~~ocatoon := ~ " d ----' E ementCroup • Ann b"tc:s elementGroupld 9 Annblltes c:lememTypeld ,conl tlename eemenu _ 1_ , ~ t.~ ~ cc l1.J JsonLut'-1oct'lc:d Jsonl..ut'Aocif,c:d n;amc: sortOrde r Rel.'lt on·"s~"'c;===i " h t ps narrc: Rc: o'!t onhops drilv.ongTypu Element ess er w h /'.,.» elementCroup AUt ib'->ttS dra~o, ng(()Q(dX c:lementQ..estlons c:lementRequ lremen ts ~;::·~~;=~:n V ·,t. lm0 t. c:lc:mc:nts elementld ~ clcmentll.umber jsonl..ut'-1oditied Eltmc:ntQue stlon ~ Attrobutes c: c:mc:ntQI.esbonld ~~ n.1me 'f Relat o n Sh pS O s no nelpPnotofoename !-------c:iementAnswc:rs help-tltt nchesMax Code ~nd nches4ln json~tlod • tied E c:mentAnswc:r 0 emc ntA.11s"'..: rPhoto pnoto.AI owNOt e~ J Auro butes Aur iba.tes :>hotoM.1xCount OJnswc: rlnt crc;atcdOn ohotoM nCount photoRc:qu rel'l.otcs p cl(L siC no cc:s quest Of'ITtxt .'lnswerText created On e emen!An~"erld etementAnswerPhotold gpsUto tude gpslottgltude no SQL• gpslatttudc: t'ludong quest on- 'fpe gpslong tude jsonLOJst'Aodoficd required jsonLmVoct o foed .'lnMod fied sortOrdc:r IJ.stl'-'od ned ~otor den~e tc:xtMaxleng th Re ilto ons"'lps photoNotts Rc: ilto oqhips e ement : :::~~~;~;:rs "< _-------------------,fmentAn~"-C!rPhotos ; +u Wednesday, February 13, 13
  • 37. To Re cap... A ndroid sucks. Mobilize your web assets. he mob ile web first. Con sider t Avoid SQL & SOAP. Use RESTful APIs. Co reData i s way w orth it. Wednesday, February 13, 13
  • 38. Mat llowaoydinaire) t Ga a r o bile Develo per Extr (Fre elance M matt@architactile.c om 918 -808- 3072 Wednesday, February 13, 13