How to get own device token? [closed] - iphone

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is it possible to get your own device token from my own iPhone? I need it because I want to test Push-Notifications...
Thanks

You will need to use the -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; method. Below is an example that will output your devices token as well as set it to a string.
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(#"APN device token: %#", deviceToken);
NSString *deviceTokenString = [NSString stringWithFormat:#"%#",deviceToken];
}
But, you should really be doing this already though so that you know where to send the notifications for your users, aren't you?
Edit after further clarification comment:
You weren't very specific at all in your question. To answer your more detailed question, you can't display it. As it is unique for each device AND each app. So your token for AppA is not the same as AppB.

The device token needed for push notification you will have in a callback function if you have subscribed to push notification. Until that not, unless you write doen the previous value.
Note the token for app in development / debug mode it is different from release/ad-hoc mode!!!
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(#"My token is: %#", deviceToken);
}
Please look at this tutorial. Also it is not working with simulator, and jailbroken devices

Related

Tutorial for a Tutorial in IOS7 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm already finishing an app and I would like to make a tutorial embedded in the App, like those that appear as an overlay, explaining the functionality of every button, in the app until the user taps the screen.
Another option could be to show a tutorial the first time a user opens the app, but I don't know how to identify if is the first time a user opens the app.
Does anyone knows a good tutorial that shows how to do this?
Thank you!
Follow this link HERE. Its a tutorial for a tutorial you are trying to create using UIPageViewController.
and here is how you can detect the first time user loads the app:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:#"HasLaunchedOnce"])
{
// app already launched
}
else
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"HasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
// This is the first launch ever
}
}
Hope this helps!

Unlock an existing functionality after successful completion of InAppPurchase Process [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking at in-app purchases.
Essentially all the content is there and I just want an in-app purchase that lets the user purchase an item, and upon successful completion of the purchase will unlock an existing functionality.
I only need to unlock existing content.
Are there any plugins to allow this kind of thing?
When user successfully complete the purchase, your program will receive a delegate callback of
- (void)completeTransaction:(SKPaymentTransaction *)transaction;
and then you can record this transaction and post a NSNotification to notify other objects in your app to unlock some premium functionalities.
Also, you can store values in NSUserDefaults for next time to decide whether the functionality is unlocked.
Here is a sample code as reference.
- (void)completeTransaction:(SKPaymentTransaction *)transaction {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setBool:YES forKey:#"proVersionEnabled"];
[[NSNotificationCenter defaultCenter] postNotificationName:#"proVersionEnabledNotification" object:nil];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
Your question is very generalized.
You need to be more specific. After successful transaction you just can use NSUserDefaults value or iOS Keychain to get value of a flag and unlock particular feature of your app.
Also I have a tutorial which could help you with this
http://nixsolutions.com/blog/development/iphone/in-app-purchase-tutorial/
Hope this helps.
Just set a bool in the user defaults if the premium content was puchased and check that bool to decide if you do or don't show the premium content.

android/iphone app can steal your contacts and sms? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Can a (jailbroken OR not) smart phone app access your private info, contacts, sms and sends back to collector?
On a stock Android phone, an application can request permission to access all of those items.
On a stock iPhone, an application can access contacts, but not SMS etc.
On a jailbroken iPhone, an application can do whatever it wants.
On android an app can steal your information and send them back but when you install them from market you can see which things the app wants access to.
I don't know about the iPhone.

How can i implement apple Push Notification ?? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i am new in iphone development,i want to implement push Notification in my application. i have no idea about that. anyone give sample code.
Firstly, you have to either rent or own a server that is responsible for communicating with Apple's APNS servers. Yes, when pushing notifications to your app's users, your server has to first push it to Apple and have Apple transfer those notifications to specific users on your behalf.
And second, override and implement the following methods in your AppDelegate's .m file:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//You probably already implemented this one
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
And test your code and your server with Apple's Sandbox server before you put your app into production.
Follow Apple's Documentation.

iPhone - Is it possible to override silent mode or have a recursive alert sound with push notification? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to write an application for the iPhone where the user will be notified of events such as deadlines. I am looking to override the silent mode and possibly have the notification sound loop until the user activates the application. Any info or documentation would be appreciated.
Thanks.
Overriding the OS sound settings in this manner, even if it were possible, would surely result in rejection during the review stages (if the reviewer caught this behaviour).
Think about what you're doing, and ask yourself if you think your user would appreciate this "feature". To me, the answer is clearly no.
Apple tends not to permit activities that could be so easily used to abuse the user. If I enable silent mode, there's a reason.
I'll give a tip on how I solved this problem, which may be a little different.
I was building an app where I wanted the user to be able to preview an MP3 clip, even if they had the phone on silent.
The way I went about this was first, importing the Audiobox framework <AVFoundation/AVFoundation.h> at the start of your file and then later in my code before I initialized my AVAudioPlayer I did:
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayback
error: nil];
Worked like a charm. It may not be what the OP needed, however.