Discussion Forums  >  Xcode, Errors, Installing, Configuring

Replies: 37    Views: 220

FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
04/27/17 02:50 AM (4 months ago)

One signal ios key and id

Ive got one signal all setup on my ios app, followed als instructions and i have already got one signal set up and working on a diff app,
problem ive got is no errors on either xcode or one signal but im not getting any users, Im trying to find where the OneSignal App ID in the xcdode project, can someone point me to where i will find it in the xcode code for the app.
cheers
Sean
 
miku
Aspiring developer
Profile
Posts: 391
Reg: Feb 20, 2014
zagorje ob savi
10,460
like
04/27/17 06:32 AM (4 months ago)
Hi,
in appDelegate.m find: //didFinishLaunchingWithOptions...
There you have: appId:@"xxxxxxxx" which is OneSignal AppID.
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/27/17 07:11 AM (4 months ago)
all i have is this

@implementation giulianos_appDelegate


//didFinishLaunchingWithOptions...
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[BT_debugger showIt:self message:[NSString stringWithFormat:@"didFinishLaunchingWithOptions (iOS)%@", @""]];

/*
Storyboard App
---------------------------------------------------------------------------
This app launches using a Storyboard. The Storyboard Entry Point (iOS) is
intentionally left blank. If you look at the project settings (in Xcode) you'll
see there is no value for "Main Interface" entry. Additionally, there is
not an entry in the BT_info.plist for UIMainStoryboardFile. Again, this is intentional.


The app instantiates an instance of the BT_loading class, which uses the BT_loading.storyboard
file as it's interface. This becomes the launching point for the app. See the BT_loading.m
file to see how it then instantiates an instance of a BT_application, sets up it's initial
view controller, then continues to show the app's home screen.

*/
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/27/17 07:28 AM (4 months ago)
ive looked at the app that i did get one signal working on andyour text is there, ive obviously forget to install something, but its not showing any errors,
Ive looked at both files from both projects .m and .h theres quite few differances between them, the only differance i did between the 2 projects is updated the files from 1 signal at git hub, the project that works onesignal sdk 1.13.3 and the one im using with new project is one signal sdk 2.5.2,
could that be it guys
Thanks
Sean
should i go back to version 1.13.3
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/27/17 09:19 AM (4 months ago)
update, managed to figure it out thanks to old post of mikus <a href="https://www.buzztouch.com/forum/thread.php?fid=B91CCC6590E28D9FA580BF1&tid=B91CCC6590E28D9FA580BF1" target="_blank" rel="nofollow">https://www.buzztouch.com/forum/thread.php?fid=B91CCC6590E28D9FA580BF1&tid=B91CCC6590E28D9FA580BF1</a>

little red problem on
initWithLaunchOptions:launchOptions
No visible @interface for 'OneSignal' declares the selector 'initWithLaunchOptions:appId:handleNotification:'
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/27/17 09:23 AM (4 months ago)
heres what i have now in .m file
#import "giulianos_appDelegate.h"
#import "BT_loading.h"

@implementation giulianos_appDelegate


//didFinishLaunchingWithOptions...
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[BT_debugger showIt:self message:[NSString stringWithFormat:@"didFinishLaunchingWithOptions (iOS)%@", @""]];

/* ajm below added to support onesignal */
self.oneSignal = [[OneSignal alloc
WITH THE RED X HERE ~ initWithLaunchOptions:launchOptions
appId:@"xxxxxxxxxxxxxxxxxxxxxxxxxxx"
handleNotification:^(NSString* message, NSDictionary* additionalData, BOOL isActive) {
// This function gets called when a notification is received while the app is in focus.
// code based on the example provided with SDK
AudioServicesPlaySystemSound(1007 ); // play system sound, see http://iphonedevwiki.net/index.php/AudioServices
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); // vibrate
NSString* messageTitle = @"Alert";
NSString* fullMessage = [message copy];
if (additionalData) {
NSLog(@"additionalData: %@", additionalData);
NSString* customKey = additionalData[@"customKey"];
if (customKey)
NSLog(@"customKey: %@", customKey);
if (additionalData[@"inAppTitle"])
messageTitle = additionalData[@"inAppTitle"];
if (additionalData[@"actionSelected"])
fullMessage = [fullMessage stringByAppendingString:[NSString stringWithFormat:@"\nPressed ButtonId:%@",
additionalData[@"actionSelected"]]];
}
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:messageTitle
message:fullMessage
delegate:self
cancelButtonTitle:@"Close"
otherButtonTitles:nil, nil];
[alertView show];
// show the alert as a pop-up
// Check for and read any custom values you added to the notification
// This done with the "Additional Data" section the dashboard OR setting the 'data' field on our REST API.
}];
/* ajm above added to support onesignal */

/*
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/27/17 11:26 AM (4 months ago)
Hey Sean.
Try this (with your appID) in your appDelegate.m:

//didFinishLaunchingWithOptions...
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[BT_debugger showIt:self message:[NSString stringWithFormat:@"didFinishLaunchingWithOptions (iOS)%@", @""]];

id notificationReceiverBlock = ^(OSNotification *notification) {
NSLog(@"Received Notification - %@", notification.payload.notificationID);
};

id notificationOpenedBlock = ^(OSNotificationOpenedResult *result) {
// This block gets called when the user reacts to a notification received
OSNotificationPayload* payload = result.notification.payload;

NSString* messageTitle = @"giulianos";
NSString* fullMessage = [payload.body copy];

if (payload.additionalData) {

if(payload.title)
messageTitle = payload.title;

NSDictionary* additionalData = payload.additionalData;

if (additionalData[@"actionSelected"])
fullMessage = [fullMessage stringByAppendingString:[NSString stringWithFormat:@"\nPressed ButtonId:%@", additionalData[@"actionSelected"]]];
}

UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:messageTitle
message:fullMessage
delegate:self
cancelButtonTitle:@"Close"
otherButtonTitles:nil, nil];
[alertView show];

};

id onesignalInitSettings = @{kOSSettingsKeyAutoPrompt : @YES};

[OneSignal initWithLaunchOptions:launchOptions
appId:@"XXXxXxXX-XXXx-xxxx-xxxx-xxxxxxxxxxxx"
handleNotificationReceived:notificationReceiverBlock
handleNotificationAction:notificationOpenedBlock
settings:onesignalInitSettings];
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/27/17 12:37 PM (4 months ago)
Thanks dog
That got rid of my error and enabled fresh install of app to register with signal console, i send a test app, it all go,s through the sigal system, shows that its arrived, but the app doesn't receive the message and freezes up, below is the logcat from device, is it a signal problem or code, thanks for your help guys ,rely appreciate it
Sean

[__NSCFDictionary length]: unrecognized selector sent to instance 0x144ea1220
2017-04-27 20:34:59.884 giulianos[2431:1200543] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary length]: unrecognized selector sent to instance 0x144ea1220'
*** First throw call stack:
(0x183095900 0x182703f80 0x18309c61c 0x1830995b8 0x182f9d68c 0x18817966c 0x1881797d8 0x1885fad54 0x187e8edf0 0x1839b6130 0x1839b5ba4 0x1839b58fc 0x187e8fa40 0x1839b5500 0x187e8f5e0 0x187e8f824 0x187e8f5f0 0x187d82a38 0x187e8f974 0x1839b5500 0x187e8f5e0 0x187e8f824 0x187e8f5f0 0x187d82a38 0x1880a50bc 0x187e8f974 0x1839b5500 0x187e8f5e0 0x187e8f824 0x187e8f5f0 0x187d82a38 0x187e8f974 0x1839b5500 0x187e8f5e0 0x187e8f824 0x187e8f5f0 0x187d82a38 0x187e8f974 0x1839b5500 0x187e8f5e0 0x187e8f824 0x187e8f5f0 0x187d82a38 0x187e8f974 0x1839b5500 0x187e8f5e0 0x187e8f824 0x187e8f5f0 0x187d82a38 0x187d822ec 0x1839b5500 0x187d82194 0x187d8fb80 0x1881dac0c 0x1880e42fc 0x1880e2414 0x188038b70 0x188046030 0x187d79c24 0x18304c588 0x18304a32c 0x18304a75c 0x182f79680 0x184488088 0x187df0d90 0x1000f5dc0 0x182b1a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/27/17 08:34 PM (4 months ago)
The "dictionary length" crash rings a bell, but I can't remember what I did to fix it.
Do you have any warnings in xCode that could shed some light?

I would be happy to compile your code and see if I can fix it, if you want to upload it to me.
(-no guarantee-)
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/27/17 11:25 PM (4 months ago)
that would e great Dog, thanks, what code do you need do my jason or whole file
Thanks
jason
oh ps no warnings in xcode
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/28/17 07:35 AM (4 months ago)
Hey Sean.

Send me a PM with your best email address and I will give you a dropBox link.
Zip your project and upload it to my dropBox and I will take a stab at it.
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/28/17 11:28 AM (4 months ago)
Thanks so much big dog, i will zip it up and set up a dropbox for it, my email is <a href="mailto:sean@theappbureau.com">sean@theappbureau.com</a>
cheers dude :)
im still amazed at the help you get from the gurus on here, wouldnt be buzz without it :)
ps ive emailed you link
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/28/17 01:25 PM (4 months ago)
For starters open AMG_menuButtons.m and on lines 217 & 318

Change NSDictionary to NSMutableDictionary

In your app capabilities / Background modes, make sure you have background fetch & remote notifications checked
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/28/17 01:45 PM (4 months ago)
AlanMac's instructions are due for an upgrade. Remove these items;

Targets /Build Phases /Link Binary With Libraries:
Remove OneSignal Framework.


Targets /Build Settings /Other Linker Flags:
Remove -ObjC

Recompile to a real device, send a push, and let me know how it goes.
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/28/17 01:54 PM (4 months ago)
One last thing.

In your Frameworks I only see the file "OneSignal.Framework."
You may need to re-drag over the entire OneSignal.Framework that includes Headers sub folder and OneSignal.h
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/29/17 03:10 AM (4 months ago)
Tried all that . recpmpiled and still no message and app freezes, then tried again and got theses errors
Apple Mach-O Linker (ld) Error Group
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_OneSignal", referenced from:
objc-class-ref in giulianos_appDelegate.o
"_kOSSettingsKeyAutoPrompt", referenced from:
-[giulianos_appDelegate application:didFinishLaunchingWithOptions:] in giulianos_appDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
thanks for your help Dog :)
sean
ps ive zipped up the project after making the changes and uploaded to our dropbox, if that helps :)
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/29/17 07:30 AM (4 months ago)
Did you use the coco pods install from the OneSignal site by chance?
I did not have any of these issues running your app on the simulator.
Can't run it on a device since I'm not on your apple cert.
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/29/17 07:34 AM (4 months ago)
no i followed alans method, should i restart and use the one signal cocoe pods, never used it before, do you want me to add you to the apple cert if that helps
sean
everything works correctly on live device, registers with signal, sends the message and one signal confirms its been sent to the device, the app then just locks
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/29/17 07:58 AM (4 months ago)
No to cocopods.
I will take another look at it tonight.
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/29/17 08:04 AM (4 months ago)
thanks mate, realy appreciate it, i wll sort you out drink if you can fix it, wont be big drink as i dont charge much for apps, but you should be able to buy some sun tan oil or something lol
Thanks
Sean
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
04/29/17 11:19 AM (4 months ago)
Hi, I'm a bit late to the party. @Red Dog, you are right about my recipe for this being out of date. It has changed a bit. BT4 has a lot of the necessary code built in to display the message as an alert and OneSignal have tried to simplify the process.

I built a project today doing it the new way. Worked OK for me and I have updated my doc on how I do it: http://bit.ly/2psvpNP
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
04/29/17 11:21 AM (4 months ago)
Also, thanks for the tip on changing NSDictionary to NSMutableDictionary

I'm not sure if it was causing a problem and Xcode didn't flag it as a warning, but I have changed it for my next update.
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
04/30/17 03:43 AM (4 months ago)
Sean, I'm thinking you have added frameworks correctly if the app receives a push.

I found the new OneSignal way adds less code than before. I have now tried it on two apps, one that I downloaded and started from scratch. Neither crashed for me. I tweaked my howto, give it a try?

Alan
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 05:13 AM (4 months ago)
Hi Al, decided to restart the app from start re your guide, every thing going ok until i get to the appdel.m file and adding the last section in yellow,
where in the file does that bit go as evertime ive tried to do it i instantly get 3 red errors.

//didFinishLaunchingWithOptions...
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[BT_debugger showIt:self message:[NSString stringWithFormat:@"didFinishLaunchingWithOptions (iOS)%@", @""]];
TRIED HERE =

/*
Storyboard App
---------------------------------------------------------------------------
This app launches using a Storyboard. The Storyboard Entry Point (iOS) is
intentionally left blank. If you look at the project settings (in Xcode) you'll
see there is no value for "Main Interface" entry. Additionally, there is
not an entry in the BT_info.plist for UIMainStoryboardFile. Again, this is intentional.


The app instantiates an instance of the BT_loading class, which uses the BT_loading.storyboard
file as it's interface. This becomes the launching point for the app. See the BT_loading.m
file to see how it then instantiates an instance of a BT_application, sets up it's initial
view controller, then continues to show the app's home screen.

*/

//hide status bar on launch...
[[UIApplication sharedApplication] setStatusBarHidden:TRUE withAnimation:UIStatusBarAnimationNone];

//setup the window on launch...
[self setWindow:[[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]];
[self.window setBackgroundColor:[BT_color getColorFromHexString:@"#FFFFFF"]];

//load initial storyboard, "BT_loading"...
UIStoryboard *launchStoryboard = [UIStoryboard storyboardWithName:@"BT_loading" bundle:nil];
BT_viewController *launchViewController = [launchStoryboard instantiateViewControllerWithIdentifier:@"BT_loading"];

//set the rootViewController on the window to the BT_loading storyboard...
self.window.rootViewController = launchViewController;
[self.window makeKeyAndVisible];


//return...
TRIED HERE =
return TRUE;
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 05:27 AM (4 months ago)
these are the error lines
this line.
// replace appId value in quotes with your OneSigna
l App ID
[OneSignal initWithLaunchOptions:launchOptions
appId:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
[BT_debugger showIt:self message:[NSString str
ingWithFormat:@"Initialised OneSignal (iOS)%@", @""
]];
//AMG Additions from this point for OneSignal up to
this line.
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
04/30/17 06:15 AM (4 months ago)
Either place should work. My guess? Check the step about adding the framework? Or if you cut and paste from a PDF things can go funny, maybe retype?
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 06:23 AM (4 months ago)
your feckin guru you alanmac, now to test the whole thing , finger crossed :)
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/30/17 06:56 AM (4 months ago)
.... holding my breath
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 07:04 AM (4 months ago)
And it all works, thanks Big Dog and Al, much appreciated, just need the head gurus to fix Android now and i can start selling apps again, push was big one which you guys have sorted for me, cant sell apps these days without push, but you cant sell an app without Android, iv actually had to get real job in the meantime lol
Thanks again guys, will send you both drink when the client pays for the above app, you wont be able to get sun tan oil each, but maybe bargain bucket at KFC :)
 
Red Dog
buzztouch Evangelist
Profile
Posts: 805
Reg: Jun 16, 2011
Southern Califo...
18,800
like
04/30/17 07:22 AM (4 months ago)
Great news!

Very nice looking app too.

Thanks AlanMac for updating the instructions. Maybe it can be added to the "how to's" guides?
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 07:26 AM (4 months ago)
feel free to use it as template big dog, ive added alans new guide to my guides as it worked flawlessly , thanks to you both again :)
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
04/30/17 08:14 AM (4 months ago)
I love a happy ending. Let us know when the app hits the app store, I'd like to take a peek.
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 08:32 AM (4 months ago)
Putting the update in tomorrow, lets see if the new gestapo apple reviewers will let it go through, i never managed to get that last update of different app in, so fingers crossed :)
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
04/30/17 11:02 AM (4 months ago)
sorry to bother you guys, ive archived my app, but im getting these errors while trying to upload to store, ive never had before.

Symbols tool failed (show logs)
giulianos_2017-04-30_18-46-18.237.xcdistributionlogs
IDECodesignResolver.log
IDEDistribution.critical.log
IDEDistribution.standard.log
IDEDistribution.verbose.log

Archive upload failed due to issues
unable to validate your application
the path'/var/folders/21/hz_2vbps3ni7ziyg632tfj0m0000gn/t/xcodeDistPipeline.5db/Packages/giulianos.ipa'does not contain a file

its amazing how fast xcode takes me from exileration to manic depression in such a short time lol :)
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
04/30/17 12:05 PM (4 months ago)
I have never seen that one. I am guessing Xcode can't find the output. I would clean, retry and look at stack overflow
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
05/01/17 04:52 AM (4 months ago)
im going through stack now trying to fix it, one think ive noticed, when im compiling in binary and entitlements it has
giulianos app 5 entitlements and just beneath that it has
onesignal (no entitlements

also in the app when compiling to run i get
2 orange symantic issue
/Users/theappbureau/Desktop/giulianos_iOS_BTv4.0.1/giulianos_iOS_BTv4.0.1/BT_Plugins/AMG_ButtonPlus/AMG_menuButtons.m:327:29: Incompatible pointer types assigning to 'NSMutableDictionary *' from 'NSDictionary *'
could that be something

update thatnks to stack
RESOLVED :



Untick : include app symbols for your application on Validate and upload to App Store.
 
AlanMac
Aspiring developer
Profile
Posts: 2604
Reg: Mar 05, 2012
Esher, UK
37,040
like
05/01/17 05:17 AM (4 months ago)
Glad you got there. On the Incompatible pointer types assigning to 'NSMutableDictionary *' from 'NSDictionary *'

Did you make the changes suggested by @RedDog?
 
FunkyMonkey
Aspiring developer
Profile
Posts: 1041
Reg: Aug 07, 2013
blackpool
13,210
like
05/02/17 10:07 AM (4 months ago)
Yes i didn (pointer types assigning to 'NSMutableDictionary *' from 'NSDictionary )
pleased to say the app was submitted tea time yesterday and just got approved, its a very simple app and i don't charge clients a lot to to it, as my coding skills are very limited, but what gets me is the last app i tried to update, got rejected 5 times, so i didn't bother updating it, this new updated app had less features that the previous one, so it really is waiting couple weeks and getting a different reviewer, heres the link for you Alan, https://itunes.apple.com/us/app/giulianos/id993614808?ls=1&mt=8
Again soon as the client pays me i will send you both little drink for your great advice and help.
Sean
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.