Topic
  • 6 replies
  • Latest Post - ‏2012-06-01T13:00:35Z by SystemAdmin
SystemAdmin
SystemAdmin
570 Posts

Pinned topic Push Notification sample for iOS

‏2012-05-30T17:30:19Z |
Hi,

I'm trying to get the push notification sample (module 21) to work with iOS.

The steps I've taken so far:

1. Downloaded sample -> imported -> removed Android env
2. Added iPhone env. Updated application.desc.xml accordingly. Using "PersistentCookie" realm instead of "PushAppRealm" (in app-desc.xml and PushAdapter.xml)
3. Acquired apns certificate, and renamed it to apns-certificate-sandbox.p12.
4. Deploy project onto iPhone.

When I click "isSubscribed" button. I get false. And the buttons below are disabled.

Is there something I've missed? Or have I misconfigured something?

Note. This is stack trace I get if I try to "Invoke Worklight Procedure" on the PushAdapter

2012-05-30 18:28:51 Starting procedure invocation on Worklight Server
2012-05-30 18:28:52 Deploying adapter: PushAdapter
2012-05-30 18:28:52 Server host: localhost
2012-05-30 18:28:52 Server port: 8080
2012-05-30 18:28:52 Procedure invocation failed
2012-05-30 18:28:52 The realm 'PersistentCookie' is not defined in the authentication configuration file.

Many thanks,
Ali
  • IdanAdar
    IdanAdar
    288 Posts

    Re: Push Notification sample for iOS

    ‏2012-05-31T10:31:35Z  
    From the sample app, have you also copied authenticationConfig.xml to your server's conf folder?
    The supplied .xml file contains the PersistentCookie realm, so if you say it doesn't find it - it sounds like it is missing.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: Push Notification sample for iOS

    ‏2012-05-31T17:52:50Z  
    Many thanks for the timely response.

    To answer your question, the realm does exist in the authConf.xml I have checked the conf everytime I get the message because it is driving me insane :( :o .

    Current setup

    Just to be on the safe side I downloaded the project again, imported it and tried to use the PersistentCookie realm once again.

    I've attached an image displaying my current server structure and where the conf lies.

    I have also attached this simple project.

    What happens

    When I deploy the app on the iPhone it does not enable the subscribe button. (Or any of the buttons that rely on WL.Client.Push.onReadyToSubscribe)

    Just for testing purpose I removed \$('SubscribeButton').disable(); from wlCommonInit(); to see what happens, I get the following message:

    PushApplication3911:707 ERROR Can't subscribe, notification token is not updated on the server.

    Any help would be greatly appreciated.
    Many thanks,
    Ali R
  • IdanAdar
    IdanAdar
    288 Posts

    Re: Push Notification sample for iOS

    ‏2012-05-31T20:30:42Z  
    I don't understand, why are you changing the contents of application-descriptor.xml? You should be able to run the sample as-is, except for the additions of the certificate, the iPhone environment (and its relevant settings in application-descriptor) as well as adding the authenticationConfig.xml file to your server. That's it.

    What are your Worklight Server and Studio versions?
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: Push Notification sample for iOS

    ‏2012-05-31T21:13:27Z  
    Because I was running out ideas :). Thought I could give different realms a try.

    Server Version: 4.2.2.1283
    Studio Version: 4.2.1.1189

    Also by "iPhone environment (and its relevant settings in application-descriptor)" do you mean just adding the pushSender element or is there more to do?

    Could it possibly be an issue with my certificate even tho it deploys successfully on the iPhone?

    Thanks again for the quick response :)
  • IdanAdar
    IdanAdar
    288 Posts

    Re: Push Notification sample for iOS

    ‏2012-06-01T04:43:24Z  
    First of all, you should use the same version of the server and plug-in.

    After you do the above:
    1. Import the sample project to Eclipse
    2. From the conf folder in the project, copy authenticationConfig.xml and replace yours with the one you copied. It should sit in <your-server-installation>/serve/conf/
    3. Add the iPhone environment.
    3.1 Add the PushSender password
    3.2 Add the push-enabled certificate to the project
    4. Build and deploy
    5. Open Xcode project in Xcode
    6. Choose the right developer signer
    7. Run on device

    I can't help you with steps 3.2 and 6, as it is on you to create the right certificates for this.
    Also, try to look at other iOS/Push related threads here in the forum. They may had the same problem you're facing.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: Push Notification sample for iOS

    ‏2012-06-01T13:00:35Z  
    Thank you very much again.

    I've tried everything in the books to get this work. I've sent a response to another thread (Link) that had a similar issue. I want to know how he/she got around the issue.

    Many thanks,
    Ali R