2015-02-09 13 views
7

Sto creando un'app Jailbreak che viene installata in/Applicazioni. Non importa quello che faccio, non riesco a far funzionare le notifiche push.Servizio di notifica Apple per l'app Jailbreak

ho:

  • Creato la necessaria App ID nella console Apple Developer,
  • creati tutti i certificati e le disposizioni necessarie,
  • installato il sopra, ove necessario,
  • Firmato l'applicazione con il certificato corrispondente,
  • Aggiunti gli elementi trovati nel file .MobileProvision alle autorizzazioni,
  • Picchia la testa contro il muro.

I sintomi sono i seguenti. Mi registro con successo con APNS e ottengo un token dispositivo. Il token del dispositivo è stato inviato correttamente al mio server. Il mio server si collega con successo al server APNS, invia con successo una notifica push al server APNS senza alcun tipo di reclamo e la mia app non riceve mai, mai, il messaggio Push. Si perde semplicemente. Non importa se collaudo con un dispositivo ios 7 jailbroken o un dispositivo ios 8 jailbroken. Per quanto posso dire, entrambi questi dispositivi stanno ottenendo con successo messaggi APNS per altre app.

Ho provato entrambe le impostazioni di sviluppo e produzione.

C'è qualche passaggio necessario per le app di jailbreak che mi manca che viene normalmente fatto per te quando un'app viene registrata regolarmente? Le app di sistema non sono in grado di essere app APNS (ciò sembrerebbe piuttosto strano)?

Ecco un po 'di codice. Phone-side (Swift):

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{ 
    if Global.OSVersion() < 800 
    { 
     application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert 
                | UIRemoteNotificationType.Badge 
                | UIRemoteNotificationType.Sound); 
    } 
    else 
    { 
     var types: UIUserNotificationType = UIUserNotificationType.Alert 
              | UIUserNotificationType.Badge 
              | UIUserNotificationType.Sound; 
     var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, 
                       categories: nil); 
     application.registerUserNotificationSettings(settings); 
    } 
    application.beginReceivingRemoteControlEvents(); 
} 

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) 
{ 
    let bytes: [Byte] = deviceToken.getBytes(); 
    var token: String = ""; 
    for byte: Byte in bytes 
    { 
     token += NSString(format: "%02.2hhx", byte); 
    } 
    // code to send token to server goes here... 
} 

func application(application: UIApplication, 
       didReceiveRemoteNotification userInfo: [NSObject : AnyObject], 
       fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) 
{ 
    let command: String = userInfo["Command"] as String; 
    // code to process command goes here... 
} 

codice Server (C#):

private bool SendIPhone() 
    { 
     isSent = false; 
     PushBroker pushBroker = new PushBroker(); 
     try 
     { 
      pushBroker.OnChannelCreated += pushBroker_OnChannelCreated; 
      pushBroker.OnChannelException += pushBroker_OnChannelException; 
      pushBroker.OnChannelDestroyed += pushBroker_OnChannelDestroyed; 
      pushBroker.OnServiceException += pushBroker_OnServiceException; 
      pushBroker.OnNotificationFailed += pushBroker_OnNotificationFailed; 
      pushBroker.OnNotificationSent += pushBroker_OnNotificationSent; 
      pushBroker.OnNotificationRequeue += pushBroker_OnNotificationRequeue; 
      pushBroker.OnDeviceSubscriptionChanged += pushBroker_OnDeviceSubscriptionChanged; 
      pushBroker.OnDeviceSubscriptionExpired += pushBroker_OnDeviceSubscriptionExpired; 
      pushBroker.RegisterAppleService(new ApplePushChannelSettings(XXXConfig.APNSIsProduction, 
                     XXXStatic.APNSCertificate, 
                     XXXConfig.APNSPassword)); 
      AppleNotification notification = new AppleNotification(); 
      notification.DeviceToken = cloudToPhoneID; 
      notification.Payload.Alert.Body = "This is a test"; 
      notification.Payload.Sound = "Alarm.wav"; 
      notification.Payload.Badge = 5; 
      notification.Payload.CustomItems["content-available"] = new Object[] { "1" }; 
      notification.Payload.CustomItems["Command"] = new Object[] { "TestCommand" }; 
      pushBroker.QueueNotification(notification); 
     } 
     finally 
     { 
      pushBroker.StopAllServices(); // This will force us to wait until we have sent what's in the queue... 
     } 
     return isSent; 
    } 

    void pushBroker_OnNotificationSent(object sender, INotification notification) 
    { 
     isSent = true; 
    } 

C'è un sacco di codice non sto mostrando che tutte le opere in quanto dovrebbe. SendIPhone restituisce sempre true e può essere impostato su true quando viene chiamato pushBroker_OnNotificationSent.

I diritti:

<dict> 
    <key>application-identifier</key> 
    <string>REMOVEDFORPRIVACY</string> 
    <key>aps-environment</key> 
    <string>development</string> 
    <key>com.apple.developer.team-identifier</key> 
    <string>REMOVEDFORPRIVACY</string> 
    <key>get-task-allow</key> 
    <true/> 
    <key>keychain-access-groups</key> 
    <array> 
     <string>REMOVEDFORPRIVACY</string> 
    </array> 
</dict> 

Che cosa mi manca o non c'è un percorso non da qui?

+0

Un errore comune con notifica push è quello di utilizzare il vostro certificato di distribuzione, ma spinta invio al server di notifica di sviluppo spinta di Apple. Sei sicuro di aver impostato il tuo ambiente di distribuzione/sviluppo giusto? – Emilie

+0

Sì.Al momento ho solo certificati di sviluppo per questo progetto e ho eliminato tutto ciò che riguarda la produzione proprio per questo motivo. Grazie mille del suggerimento, ma penso di averlo coperto. – user3701103

+0

Hai mai funzionato? Sto avendo lo stesso problema. – Darren

risposta

0

Non lo test, ma se so che Apple consente le notifiche push nella cartella dell'app root di iOS (basta guardare l'applicazione "tips"), quindi potrebbe essere un problema con il certificato, quindi forse questo aiuto:

http://www.hackthatphone.com/3x/push.html

Questo è un tutorial per i dispositivi iOS hackctivated, ciò che non hanno ottenuto i certificati validi per le notifiche push, ma può anche aiutare.

enter image description here

+1

L'app Suggerimenti utilizza le notifiche locali. Si tratta di notifiche a tempo dall'app stessa e non inviate tramite APNS. – Darren