Apple Push Services for Phonegap App

0 votes
Hi!

I need to implement Push services for my Apple App. As,  I am very new to the designing of iPhone Apps so i am unable to implement push services for my app. Need help.

Thanks!

Regards,

Prabhjas Singh
asked Nov 11, 2015 in App42 Cloud API-BaaS by prabhjassinghbajwa (25 points)

1 Answer

0 votes
 
Best answer

Hello Prabhjas,

You can follow this tutorial to create certificates, provisional profile and .p12 files required forApple push notification. 

Let me know if you face any problem.

Thanks.

answered Nov 12, 2015 by rajeev.etc (1,660 points)
selected Nov 20, 2015 by prabhjassinghbajwa
Hye Vishnu,

After long time i messaged you because my apple developer account just now got approved. And i tried creating .p12 file but when i try to export and save that file it doesn't show me to make .p12 file. I am just attaching that screenshot please check and let me know what to do?

https://www.dropbox.com/s/sudcoomb5f52a0a/Screen%20Shot%202015-11-20%20at%2010.04.53%20AM.png?dl=0

Kind Regards,
Prabhjas Singh
Hello Rajeev,

I am able to generate .p12 file. But i am new to iPhone so could you please help me further to attach this Push Api in my IOS project.

Regards,
Prabhjas Singh
From last some days waiting for your response. If you can help it would be appreciated.
Hi Prabhjas,

Apologies from my side for late reply.
Could please let me know what is the problem you are facing? The tutorial link i have shared also explains how integrate the SDK in xcode project along with the code snippets.

If you will provide some description about the problem i will be able to guide you in a proper way.

Thanks.
Hi Rajeev,

I am sending you some screenshots of my project. As i am getting error for shephertz API file not found.
https://www.dropbox.com/sh/ftxhkv7f53qi1ew/AADcndTPfQu-XwrGH9izoUHha?dl=0
Please check this link.
Thanks!
Hi Prabhjas,
From the screenshot, what i got is the framework path is not properly set in the project setting. Please set the App42 framework path as follows:
1.Select your project in xcode left panel
2.Select your project in the middle panel under Targets
3.Click on the build settings
4.Search for Framework Search Path and set the path of the framework

Now try to run the project the error should not come now.

Let me know this does not work for you.

Thanks.
Hello Rajeev,

Please check screenshot and let me know where i am lacking.
Because when i select Framework Search Path i'm getting 3 options i.e release, debug,distribution.
So, Next what to do? Please let me know.
https://www.dropbox.com/sh/ff7l3b9h6rjom4g/AADOjqqyCM67RpOVDcdRbGSna?dl=0

Thanks!
Hi Prabhjas,

I guess the App42 framework is not added properly in the Xcode. Please add the framework as follows:

1.Download the App42's iOS framework from here(http://api.shephertz.com/cloudapidocs/download.php).

2.Unzip the downloaded file

3.Go to folder 3.4->AsyncAPI->Unzip the Shephertz_App42_iOS_API.zip

4.Drag and drop the framework file in your xode project in the left side panel of xcode.

5.Make sure to check the destination check box for "Copy items if needed" and Finish.

Now run your project, it should run now.

Thanks.
Hye Rajeev,
Everything went fine but when I am adding code for registering the device to App42Push Service. It gives an error. Providing you a link of the screenshot. Please respond as soon as possible.
https://www.dropbox.com/s/vkz1mcpasjglh7r/Screen%20Shot%202016-01-02%20at%204.59.11%20PM.png?dl=0
https://www.dropbox.com/s/cgyl1a5bmhvqbtv/Screen%20Shot%202016-01-02%20at%206.35.37%20PM.png?dl=0
Check this screenshot it will make you more clear..
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from:
      objc-class-ref in Shephertz_App42_iOS_API
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am able to solve above error by importing core telephony framework. And now able to run that application on iPhone as well it asks whether you want to receive push notifications. I have selected yes over their but not getting device tokens in my apphq dashboard.
www/index.html#/app/home
2016-01-02 21:48:59.539 Sikh Sangat NZ[473:112207] enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.
2016-01-02 21:49:00.055 Sikh Sangat NZ[473:112207] active
2016-01-02 21:49:01.273 Sikh Sangat NZ[473:112207] app42RequestCounter=1...counter=-1
2016-01-02 21:49:01.273 Sikh Sangat NZ[473:112207] app42RequestCounter=0..
2016-01-02 21:49:01.278 Sikh Sangat NZ[473:112207] Is Install Event Success = 1
I added shephertz framework and sample code as well from your tutorials but unable to get device token as well not able to send push messages to the user. I can really appreciate if you can help for the same.
After working from last 8 to 9 hours. I am able to get token in my console. But that token is not getting received in my AppHq dashboard.
app/home
2016-01-04 09:42:45.620 Sikh Sangat NZ[318:36715] app42RequestCounter=1...counter=-1
2016-01-04 09:42:45.620 Sikh Sangat NZ[318:36715] app42RequestCounter=0..
2016-01-04 09:42:45.622 Sikh Sangat NZ[318:36715] Is Install Event Success = 1
2016-01-04 09:42:45.634 Sikh Sangat NZ[318:36715] My token is: fde05a8ee1ffc54b4d7ac065f9a1f6848fdc9069eaf71ca620e85fc8127b2556

I am also sending you a link of my appdelegate.m file. Please make changes where you find it is required.
Will appreciate your help.
Thanks!
2016-01-04 09:59:31.768 Sikh Sangat NZ[329:40623] You've implemented -[<UIApplicationDelegate> application:performFetchWithCompletionHandler:], but you still need to add "fetch" to the list of your supported UIBackgroundModes in your Info.plist.
2016-01-04 09:59:31.791 Sikh Sangat NZ[329:40623] Apache Cordova native platform version 3.9.2 is starting.
2016-01-04 09:59:31.793 Sikh Sangat NZ[329:40623] Multi-tasking -> Device: YES, App: YES
2016-01-04 09:59:31.800 Sikh Sangat NZ[329:40623] Unlimited access to network resources
2016-01-04 09:59:32.020 Sikh Sangat NZ[329:40623] [CDVTimer][keyboard] 0.414014ms
2016-01-04 09:59:32.087 Sikh Sangat NZ[329:40623] [CDVTimer][socialsharing] 65.844953ms
2016-01-04 09:59:32.087 Sikh Sangat NZ[329:40623] [CDVTimer][TotalPluginStartup] 67.237020ms
2016-01-04 09:59:32.102 Sikh Sangat NZ[329:40623] SDK Version : 3.4
2016-01-04 09:59:32.388 Sikh Sangat NZ[329:40623] My token is: fde05a8ee1ffc54b4d7ac065f9a1f6848fdc9069eaf71ca620e85fc8127b2556
2016-01-04 09:59:32.391 Sikh Sangat NZ[329:40623] -[PushNotificationService registerDeviceToken:withUser:]: unrecognized selector sent to instance 0x14dcf1f0
2016-01-04 09:59:32.392 Sikh Sangat NZ[329:40623] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PushNotificationService registerDeviceToken:withUser:]: unrecognized selector sent to instance 0x14dcf1f0'
*** First throw call stack:
(0x24bc62eb 0x24392dff 0x24bcbab5 0x24bc970f 0x24af8c88 0xd74dd 0xd7429 0x37acbf 0x37acab 0x37f771 0x24b88fc5 0x24b874bf 0x24ad9bb9 0x24ad99ad 0x25d53af9 0x28dc5fb5 0xd6d8b 0x2478c873)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Hello Prabhjas,
This problem normally comes if you have added App42 SDK with Async APIs and using the code snippets of Sync APIs. I have modified the AppDelegate.m file and sent in the mail to you.

Please try and let me know if you face any problem.
Thanks.
Hi Rajeev,

I added the code provided by you but its give error for userName. It says it is not defined.

Thanks!
You just need to provide a valid user name. Please put the following code just before registerDeviceToken API call:
NSString *userName = @"Put a valid user name here";

Let me know if you face any problem.
Hi Rajeev,

I am able to solve that error by making it @"userName" in the syntax.

I just need your help for some functions.

1> When i am sending push from AppHq Dashboard.  I'm not receiving those push messages. Would be happy if you just provide me the syntax or code for the same and if required steps for the same.

Thanks!

Regards,
Prabhjas Singh Bajwa
Yeah! i'm receiving push messages. Just need your help while selecting those messages i'm unable to see them. Please provide me code for the same. I really appreciate your help.
Thanks!
Waiting for your reply!
Can you explain the problem in more detail? What is the problem you are facing? What do you mean by need help in selecting messages? Please provide more detail, it will really help me to understand the problem.
When I send push notification it is getting received at user end in its notification bar. But when I click on that message it just opens my app and I'm unable to see that notification. So help I need is could you please provide me the code by which on clicking that message it shows that push notification to the user and in background app should get opened.
Showing UI depends on the developer but the push payload at client side can be received in the delegate method in AppDelegate.m as follows:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
       NSLog(@"%s..userInfo=%@",__FUNCTION__,userInfo);
      /**
       * Dump your code here according to your requirement after receiving push
       */
}

Please place the above delegate method in the AppDelegate and parameter userInfo will be the push payload. You can just print userInfo to get its structure and then you can fetch the required value by passing the proper key.
Trying with this code.

  */
    if (state == UIApplicationStateActive) {
        NSString *cancelTitle = @"Close";
        NSString *showTitle = @"Show";
        NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Some title"
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:cancelTitle
                                                  otherButtonTitles:showTitle, nil];
        [alertView show];
        [alertView release];
    } else {
        //Do stuff that you would do if the application was not active
    }

But it says undeclared identifier state.
In last i must say you helped me lot and thanks a lot. Now I'm able to see push messages as well.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...