IOs

  1. Descarga el plugin phonegap para iOS de este link (la versión mínima suportada es la 4.2).
  2. Has un arrastrar y soltar del Finder de la carpeta PushNotification a la carpeta Pluginsen Xcode, usando “Create groups for any added folders” y selecciona “Copy ítems if needed”.
  3. Ajunta un nuevo elemento plugin en el file config.xml como especificado en sequito:
      <plugin name="PushNotification" value="PushNotification" />
  4. Modifica la clase AppDelegate.h ajuntando:
      #import "PushNotification.h"
  5. Modifica la clase AppDelegate.m ajuntando esta porción de código apena antes que el tag @end:
      /* ... */
      
      /* START BLOCK */
      
      #pragma PushNotification delegation
      
      - (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
      {
          PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
          [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
      }
      
      - (void)application:(UIApplication*)app didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
      {
          PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
          [pushHandler didFailToRegisterForRemoteNotificationsWithError:error];
      }
      
      - (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
      {
          PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
          NSMutableDictionary* mutableUserInfo = [userInfo mutableCopy];
      
          // Get application state for iOS4.x+ devices, otherwise assume active
          UIApplicationState appState = UIApplicationStateActive;
          if ([application respondsToSelector:@selector(applicationState)]) {
              appState = application.applicationState;
          }
      
          [mutableUserInfo setValue:@"0" forKey:@"applicationLaunchNotification"];
          if (appState == UIApplicationStateActive) {
              [mutableUserInfo setValue:@"1" forKey:@"applicationStateActive"];
              [pushHandler didReceiveRemoteNotification:mutableUserInfo];
          } else {
              [mutableUserInfo setValue:@"0" forKey:@"applicationStateActive"];
              [mutableUserInfo setValue:[NSNumber numberWithDouble: [[NSDate date] timeIntervalSince1970]] forKey:@"timestamp"];
              [pushHandler.pendingNotifications addObject:mutableUserInfo];
          }
      }
      
      /* STOP BLOCK */
      
      @end
  6. Ajunta también la siguiente porción de código adentro del método didFinishLaunchingWithOptions, antes del return YES:
      [self.window addSubview:self.viewController.view];
      [self.window makeKeyAndVisible];
      
      /* START BLOCK */
      
      // PushNotification - Handle launch from a push notification
      NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
      if(userInfo) {
          PushNotification *pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
          NSMutableDictionary* mutableUserInfo = [userInfo mutableCopy];
          [mutableUserInfo setValue:@"1" forKey:@"applicationLaunchNotification"];
          [mutableUserInfo setValue:@"0" forKey:@"applicationStateActive"];
          [pushHandler.pendingNotifications addObject:mutableUserInfo];
      }
      
      /* STOP BLOCK */
      
      return YES;
      
  7. Ajunta el script PushipNotification.js a tu carpeta assets/www y inclúyela en el file index.html.
  8. Ajunta el código siguiente en el método OnDeviceReady:
      Puship.PushipAppId = puship_id; // an example of puship_id might be: "h1mCVGaP9dtGnwG"
      
      Puship.APNS.Register(
      {
          successCallback: function (pushipresult){
              navigator.notification.alert("device registered with DeviceId:" + pushipresult.DeviceId);
          },
          failCallback: function (pushipresult){
              navigator.notification.alert("error during registration: "+ JSON.stringify(pushipresult));
          }
      });

Ahora puedes conectarte a Puship Manager y enviar notificaciones Push a tus diferentes Device!

Por cualquier problema con la configuración puede descargar el ejemplo aquí abajo

 

 

Para poder ajuntar tags, administrar la geolocalización e todo lo que concierne el resto de las api puship sisita la documentación común para todas las plataformas: