iOS Push Notifications doesn't work on my device - iphone

I did everything in this tutorial:
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
I created certificates, app_id and a Provisioning profile and try to use Push Notification Service with simple code below in delegate file:
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// Let the device know we want to receive push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
I tried my app on my iPad but it doesn't work. iOS doesn't ask me if I allow my app to use Push Notifications, also doesn't show my app in Settings>Notifications list.
I don't get an error while compiling or running my app..
Error
I just implemented "didFailToRegisterForRemoteNotificationsWithError" method and I am getting this error while running application
2013-03-31 00:11:10.481 PushAppCalisma [272:907] {
NSLocalizedDescription = "no valid 'aps-environment' entitlement string found for application";
}

You need to create a dev provisioning profile, linked to that specific app id (The one you created por push notifications), then remember to test it in a real device, simulator can't receive push notifications!

All right, I solved the problem. Probably people who are new to ios and uses Push Notifications first time will make this mistake.
Solution:
Do everything in this tutorial:
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
After, follow these steps:
1- Open XCode and open Organizer (Window>Organizer)
2- In left side pane, under Library section, click Provisioning Profile tab and refresh table. If you can't see the provisioning profile that you just created click "import" and select the "*.mobileprovision" file (tutorial explains how you create a provisioning profile and download provision file).
After importing, restart Xcode, click the project name
3- In Code Signing Identity (Under Build Settings tab), set attributes to Provisioning Profile for both "Targets" and "Projects" tabs.

Related

Google play leaderboards not updating the score after new score has been reported

I have been struggling with this problem for a few days... I have google play services set up, my achievements work properly, but the leaderboard doesn't seem to want to work.
This is the code that reports new score to the leaderboard:
public static void AddScoreToLeaderboard(string LeaderboardId, long score) {
Social.ReportScore(score, LeaderboardId, success => { Debug.Log("Leaderboard updated: "+score); });
}
When the function is called i get the debug message saying that the leaderboard has been updated but when i go back to the leaderboard which i display with this:
public static void ShowLeaderboardsUI()
{
Social.ShowLeaderboardUI();
}
The leaderboard is completely empty...
Any help will be appreciated.
So another user on github suggested this and it worked for me.
I had same problem with my game but i resolved that.
Follow the steps carefully:
1-Go to https://console.developers.google.com/apis/credentials
2-Remove all credentials
3-Go to https://play.google.com/apps/publish
4-In all applications tab click on your game
5-Then from left menu click on Release Management and then go to App signing
6-Copy the code of SHA1 from the App signing certificate part
7-Go back to https://console.developers.google.com/apis/credentials
8-Create credentials and choose OAuth client ID
9-Choose application type (it was android for me!)
10-paste the code you copied from part 6 in Signing-certificate fingerprint field
11-Write the package name of the game exactly in Package name field the click on create
12-Go back to https://play.google.com/apps/publish
13-click on Game Services and then click on your game
14-Click on Link apps from left menu
15-click on Link another app
16-Choose your platform (android for me!)
17-write a name
18-click on Package name field and choose your package name there
19-save and publish the linked app that you just created
20-compare the OAuth2 Client ID from linked app that you just created with Client ID in credentials you created in part 11
21-if they have the same code the leaderboard will work fine!
Hope it solves your problem!

Charboost Ad not dispalying in my app

I am integrating chart boost Ad into my iOS app. But it is not displaying any Ad.
I used the following code in 'applicationDidBecomeActive' method, to display the chart boost.
Chartboost *cb = [Chartboost sharedChartboost];
cb.appId = "YOUR_CHARTBOOST_APP_ID";
cb.appSignature = "YOUR_CHARTBOOST_APP_SIGNATURE";
// Begin a user session
[cb startSession];
// Show an interstitial
[cb showInterstitial];
What is the problem with this? Is there anything else that I have to do?
Thanking You in Advance
You can refer following links:-
https://help.chartboost.com/downloads/ios
https://github.com/ChartBoost/client-examples
The second link contains example code too, so you can refer that, and your code just need to be written in appdelegate file with proper chartboost_id and chartboost_secret. [cb showInterstitial] should be in the controller you want to display ads.
Is it giving you any error message ? You don't want to show us your appId and appSignature or you are assigning the same appId and appSignature.
If you have not created them yet please go through this link
1.Create an account.
2.Choose Apps tab then Add App
3.Fill all fields.
After that use that appId and appSignature in your code. You will able to show Interstitial popup.
If you want to show More Apps list too then you will have to add a Campaigns.
Select Campaigns tab then add Campaigns > Publish in Network and fill the detail. After that edit your app choose More App Page fill the added Campaigns name in that device and click on save. Now you can use [[Chartboost sharedChartboost] showMoreApps]; method too.
Note: If you are testing it on simulator and app is not live your Chartboost's app's test mode should be enabled.

facebook ios sdk isn't working. iphone

I followed all the steps from here http://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/ (Adding SDK & framework dependencies, Adding SQLite and the -ObjC linker flag, Adding the Facebook App ID), but I can't figure out why I get the error
Use of undeclared identifier 'FBSettings'
when I put
[FBSettings publishInstall:YOUR_APP_ID];
into
(void)applicationDidBecomeActive in AppDelegate.
Ok. I found the solution. I'm seeing the "fb_mobile_activate_app" event show up in the App Dashboard -> Insights -> App Events -> Overview
What I did:
Followed the iOS Getting Started instructions.
Added the deprecated headers, I'm sure there is a better way to do this but it worked for me. Add the headers by dragging the DeprecatedHeaders folder from the FacebookSDK.framework/Versions/A/DeprecatedHeaders folder into the Frameworks section of your Project Navigator. Choose 'Create groups for any added folders' and deselect 'Copy items into destination group's folder (if needed)'. This adds the headers as a reference.
Then I followed the Add the Facebook SDK instructions which was just adding the following code to the AppDeligate.m file right before the '#end' at the bottom of the file. This code should tell Facebook that the app was opened and that the app was installed from an ad click (DON"T FORGET TO CHANGE YOUR_APP_ID WITH YOUR FACEBOOK APP ID):
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(#"Application did become active.");
[FBSettings setDefaultAppID:#"YOUR_APP_ID"];
[FBAppEvents activateApp];
}
Added the this include to the very top of the AppDeligate.m file:
#import "FacebookSDK.h"
That's it. I now have this code in the app store and I'm getting install data for Facebook Ads.
I had the same issue but I just added:
#import <FacebookSDK/FacebookSDK.h>
And that got rid of my error.
See the demo ~/Documents/FacebookSDK/Samples/HelloFacebookSample to see it in action
You also have to import AdSupport.framework and Social.framework.

Read Device Token for iPhone Push Notification

I try to implement push notification in my iPhone application. I have create Provisioning Profile and App-id for push notification and add this certificates into Xcode. Connect iPhone device to mac system and build application through device for read Device token using the following code.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(#"didRegisterForRemoteNotificationsWithDeviceToken:\n%#", deviceToken);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(#"didFailToRegisterForRemoteNotificationsWithError:%#", [error localizedDescription]);
}
But it returns error.. like
didFailToRegisterForRemoteNotificationsWithError:no valid 'aps-environment' entitlement string found for application 2012-07-18
14:18:08.597 Z2NotifyMe[1874:707]
didFailToRegisterForRemoteNotificationsWithError:Error
Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
entitlement string found for application" UserInfo=0x11fee0
{NSLocalizedDescription=no valid 'aps-environment' entitlement string
found for application}
I have remove all old certificates in Xcode and my device, then re-create all certificate newly then execute above same code it returns same above error.
Please help solve this problem.
Thanks..
Register your device using the following code :
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
In the applicationDidFinishLaunching: method.
I hope that the device on which you are trying is not Jailbroken.
This problem occurs when your code signing identity does not have push notification enabled.
Check out this link:
http://mobiforge.com/developing/story/programming-apple-push-notification-services
http://blog.martinreichart.com/2010/01/getting-iphone-push-notifications-to-work/
I had a similar problem when I did all the steps correctly but i still got this error.
Try doing the following steps, it helped me:
1) Go to you Provisioning Profile -> Provisioning
2) Press the "edit" button in the right hand side near your app provisioning profile - > then modify
3) Make some change here, it doesn't really matter what the change is, this is just to trigger a new profile. Unselect one of the devices, or change the name, you can change it back later.
4) press the "submit" button
5) download the profile and drag it to Xcode. (delete your old profile in Xcode before)

Apple Push Notification is not delivered

I know it's a little bit flooded with Apple's Push Notification Service (APNs) issues all over StackOverflow so I actually did a lot of researches before coming up my question.
Basically, I have followed the apns-php's CertificateCreation, some tutorial like on mobiforge, and some from Matthijs Hollemans. Still, I can't get any notification posted onto my iPad 2.
Basically these are the steps I have done:
I followed the CertificateCreation tutorial, I came out with server_certificates_bundle_sandbox.pem, entrust_root_certification_authority.pem.
Followed the tutorial specified in mobiforge blog, I successfully created the App ID, provisioning profile and linked them together nicely.
Description: APNTest
Bundle Seed ID: Use Team ID
Bundle Identifier: com.learn.APN
Then I enable the Development Push SSL Certificate (only for now) using the same certificate request I have used just now to get the certs, and I download it and install it into my keychain.
I downloaded my provisioning profile in .mobileprovision file and loaded it into Xcode's Organizer under my iPad 2 device.
Next I create a simple application with only these codes:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
// Override point for customization after application launch.
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(#"%#", deviceToken);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(#"Error: %#", error);
}
Then I configure the build parameters:
Targets > Info > Build Identifier: net.learn.APN
Targets > Build Settings > Code Signing Identity > (I chose the provisioning profile I have installed just now, and it automatically selects the identical profiles for my Debug and Release)
I build and run the application on my iPad 2. My application requesting for Push Notification and after I approved it, the Token ID appeared in my console:
2012-01-19 12:43:26.345 TestAPN[578:707] <3cb08612 9392996b 5332d2fc 5adce03d 994f8959 d7a2ac38 de7bed52 c8e0778e>
I used apns-php, changed the device ID (raw 64 hexa-values), then run the sample_push.php. Script ran successfully, but my device is not receiving any notification
Then I try to use the SimplePush.php. A "Message successfully delivered" appeared, but my iPad still doesn't receive any notification from APN
Question is, which steps have I done wrongly? I'm pretty newbie in this area, and it is actually a requirement for my project that the server need to send out messages to our own applications. We are aware of the third party softwares that send APN on behalf of you, but we would like to implement one ourselves.
I also came across the "APN Feedback Service" and I written this (base on the SimplePush) but sadly it's empty. What should I do now?
<?php
// Put your private key's passphrase here:
$passphrase = '';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'server_certificates_bundle_sandbox.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://feedback.sandbox.push.apple.com:2196', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
while (!feof($fp)) {
$data = fgets($fp, 1024);
var_dump(unpack("N1timestamp/n1length/H*devtoken", $data));
}
// Close the connection to the server
fclose($fp);
Note
I am aware of the differences between development/production certs.
iPad is not jailbroken, running iOS 5.0.1
Other App Store apps receives notifications normally
XCode 4.2.1, Lion 10.7.2
I hope I'm not duplicates any of the questions here.. ;)
EDIT
When I run php simplepush.php then php feedback.php, I received a feedback with my device ID. My App is still in the iPad, so does it mean my device ID is wrong?
[root#ip-xx-xx-xx-xx SimplePush]# php feedback.php
Connected to APNS
array(3) {
["timestamp"]=>
int(1326962028)
["length"]=>
int(32)
["devtoken"]=>
string(64) "3cb086129392996b5332d2fc5adce03d994f8959d7a2ac38de7bed52c8e0778e"
}
Thanks
EDIT
After much struggling and redoing all the steps written by Matthijs Hollemans, I finally get it working. So the problem lies within the incorrect PEM file generated... hmm
I had similar problem, for me the key thing I didn't know is that the device token is different for dev and prod (for the same device).
I was using the device token I got when testing in dev to test in prod. This was working fine in dev, but when I switched to prod I kept the same device token in my python script (assuming, wrongfully, that the device token would be the same for the same device) but the actual device token registered in prod was different.
In practice this wouldn't happen as the device token is sent to the server, but when I was testing I was using hard coded device token as I didn't want to involve the server.
Hopefully this will save someone some frustration.