Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 982949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:46:44+00:00 2026-05-16T04:46:44+00:00

Help! I cant find whats wrong. My code is up and mostly running and

  • 0

Help!
I cant find whats wrong. My code is up and mostly running and i needed to incorporate Urban Air push notification and there is something wrong with my code. If there is a better or different way to incorporate this that works without my errors I would appreciate that.
I took this code from a tut of Urban Airmail. I wasnt sure what to inlude and what not to from the sample app.
Now for my code. Ill notate where I get errors They are stray / errors and expected ; b4 :
errors

If you could fix the code that would be awesome!

    //
//  SuperSlickAppDelegate.m
//  SuperSlick
//
//  Created by  on 8/2/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <SystemConfiguration/SCNetworkReachability.h>
#include <netinet/in.h> 
#import "SuperSlickAppDelegate.h"
#import "SuperSlickViewController.h"
#import "Reachability.h"




@implementation SuperSlickAppDelegate

@synthesize window;
@synthesize viewController;
#pragma mark -
#pragma mark Application lifecycle
#define kApplicationKey @"rnftzaemRp2HJMsNjwZvGQ"
#define kApplicationSecret @"X1XdTjdWQIaL72e-gXew5A"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{  
    // Override point for customization after application launch.
    Reachability *r = [Reachability reachabilityWithHostName:@"google.com"];

    NetworkStatus internetStatus = [r currentReachabilityStatus];

    if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
    {
        UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"You require an internet connection via WiFi or cellular network to use this! Try the settings app for WiFi Connectivity." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [myAlert show];
        [myAlert release];
    }



    //Register for notifications
     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)];
     //ERROR HERE in line above Stray 357

    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)_deviceToken {
        //ERROR HERE Wrong type argument to unary minus + stray

        // Get a hex string from the device token with no spaces or < >
        self.deviceToken = [[[[_deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""]
                             stringByReplacingOccurrencesOfString:@">" withString:@""]
                            stringByReplacingOccurrencesOfString: @" " withString: @""];

        NSLog(@"Device Token: %@", self.deviceToken);

        if ([application enabledRemoteNotificationTypes] == 0) {
            NSLog(@"Notifications are disabled for this application. Not registering with Urban Airship");
            return;
        }

        // this is straight out of the UA sample code
        NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
        NSString *UAServer = @"https://go.urbanairship.com";
        NSString *urlString = [NSString stringWithFormat:@"%@%@%@/", UAServer, @"/api/device_tokens/", self.deviceToken];
        NSURL *url = [NSURL URLWithString:  urlString];
        ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
        request.requestMethod = @"PUT";

        // Authenticate to the server
        request.username = kApplicationKey;
        request.password = kApplicationSecret;

        [request setDelegate:self];
        [request setDidFinishSelector: @selector(registrationSuccessMethod:)]; // if you want to do something with the token
        [request setDidFailSelector: @selector(requestWentWrong:)];
        [queue addOperation:request];
    }

    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *) error {
        NSLog(@"Failed to register with error: %@", error);
    }

    - (void)requestWentWrong: (ASIHTTPRequest *)request {

        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        NSError *_error = [request error];

        NSLog(@"ERROR: NSError query result: %@", _error);

        UIAlertView *someError = [[UIAlertView alloc] initWithTitle:
                                  @"Network error" message: NSLocalizedString( @"Error registering with notifiction server",
                                                                              @"Error registering with notifiction server")
                                                           delegate: self
                                                  cancelButtonTitle: @"OK"
                                                  otherButtonTitles: nil];
        [someError show];
        [someError release];
    }
    // Add the view controller's view to the window and display.
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}
}



- (void)applicationWillResignActive:(UIApplication *)application {
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
     */
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    /*
     Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
     */
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}


- (void)applicationWillTerminate:(UIApplication *)application {
    /*
     Called when the application is about to terminate.
     See also applicationDidEnterBackground:.
     */
}

#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    /*
     Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
     */
}


- (void)dealloc {
    [viewController release];
    [window release];
    [super dealloc];
}


@end

New Code that has troubles:

    //Register for notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)]; 
    ;}}
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)_deviceToken {
    //ERROR HERE Wrong type argument to unary minus and semi colon b4 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:46:44+00:00Added an answer on May 16, 2026 at 4:46 am

    Doesn’t look like you ever ended your application:didFinishLaunchingWithOptions: method – you should have an end brace after this line:

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes...
    

    So it should look like this:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {  
        ...
    
         [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)];
         //ERROR HERE in line above Stray 357
    }
    
    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)_deviceToken {
    
        ...
    
    }
    

    That should do it.

    For your second code block – without seeing the surrounding code it’s difficult to see what you’re trying to do…you likely shouldn’t have:

    ;}}
    

    It should probably just be:

    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cant find whats wrong with my code I am getting cannot be resolved
I can't find whats the wrong with this script. Please help me! {elseif $text[i].text
What's wrong with this set of code? I have errors and I can't find
Why doesn't this code work? Probably I've done somethig wrong, but I can't find
I am stuck. I can't find out what I do wrong, so please help
I can't seem to find where my code has went wrong. Here is my
-o changes the output filename (I found that using --help) But I can't find
I can't find anything about this on the internet, so I'm looking for help
I've been searching a lot on this, and can't find anything to help me.
I can't seem to find any help on this but under the Net tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.