title: IOS SWIFT PARSE : Pfcloud.callFunction
body: <p>i have an old app in objective C using cloudcode to send pushes to back4app platform. </p>
  
  <p>The app manage to send correctly the pushes and this is the code :</p>
  
  <pre><code>- (IBAction)inviaPush:(UIButton *)sender {
     NSString *canale;
     for (int i=0; i&lt;=4; i++) {
         switch (i) {
             case 0:canale=@"TraduzioniEDI";
                 break;
             case 1:canale=@"NavFtpYM";
                 break;
             case 2:canale=@"InvioMailFTP";
                 break;
             case 3:canale=@"VermasMto";
                 break;
             case 4:canale=@"EdiAltova";
                 break;
             default:
                  break;
         }
         NSString *testoPush =[NSString stringWithFormat:@"%@ Test Invio %@",  canale,[NSDate date]];
          [PFCloud callFunctionInBackground:@"push"
                            withParameters:@{@"channels": @[canale], @"data": @{@"alert": testoPush,@"badge":@"Increment"}}
                                     block:^( NSString *result, NSError *error) {
                                         if (!error) {
                                             NSLog(@"Risultato: %@",result);
                                         } else{
                                             NSLog(@"Errore %@",error);
                                         }
                                     }];
     }
  }
  </code></pre>
  
  <p>Running the code i receive the 5 pushes and in the info of back4app dashboard i find :</p>
  
  <p>2020-03-02T01:14:53.533Z - Ran cloud function push for user undefined with:
  Input: {"channels":["VermasMto"],"data":{"alert":"VermasMto Test Invio 2020-03-02 01:14:52 +0000"}}
  Result: "Sent!!"</p>
  
  <p>i tried to convert the program in swift
  the code to send push is :</p>
  
  <pre><code>func inviaPush (){
     var canale :String = ""
     for i in 0...4
     {
         switch i {
         case 0: canale = "TraduzioniEDI"
         case 1: canale = "NavFtpYM"
         case 2: canale = "InvioMailFTP"
         case 3: canale = "VermasMto"
         case 4: canale = "EdiAltova"
         default: canale=""
         }
         let testoPush = "\(canale) Test invio - Swift"
         PFCloud.callFunction(inBackground: "push", withParameters: ["channels": canale, "data": ["alert": testoPush,"badge":"Increment"]], block: {
              (result: Any?, error: Error?) -&gt; Void in
              if error != nil {
                 if let descrip = error?.localizedDescription{
                     print(descrip)
                 }
             }else{
                 print(result as! String)
             }
          })
     }
  }
  </code></pre>
  
  <p>in this case i receive no pushes, and in the info i find following :
  2020-03-02T01:17:25.505Z - Ran cloud function push for user undefined with:
  Input: {"channels":"NavFtpYM","data":{"alert":"NavFtpYM Test invio"}}
  Result: "Sent!!"</p>
  
  <p>2020-03-02T01:17:25.504Z - Can't count installations for PushStatus hm5hbCzDvd: bad $in value</p>
  
  <p>Comparing the info shown in the dashboard i see a difference in input</p>
  
  <p>in ojective C (Working) the in input the channel have a square bracket :</p>
  
  <p>Input: {"channels":["VermasMto"],</p>
  
  <p>while when sent from swift they have not</p>
  
  <p>Input: {"channels":"NavFtpYM",</p>
  
  <p>surely i'm calling the method PFCloud.callFunction in a wrong way.</p>
  
  <p>Any suggestion ?</p>
  
  <p>Fabrizio</p>