iOS Pebble-Watch Launching & Killing "Self.connectedWatch" - ios

When I read the sample code for Launching and killing your Pebble app:
[self.connectedWatch appMessagesLaunch:^(PBWatch *watch, NSError *error) {
if (!error) {
NSLog(#"Successfully launched app.");
}
else {
NSLog(#"Error launching app - Error: %#", error);
}
}
];
What that mean Self? How can I create something like self
in this code because I give the error the Property 'connectedWatch' not found on object of type.

Just look in the .h file and add this property between #interface and #end, like so:
#property (strong) PBWatch *connectedWatch;

Related

Error appsflyer framework file not found at AppsFlyerLib/AppsFlyerLib.h on appdelegate

I have imported AppsFlyer framework using cocoapods in my project. I am adding the #import <AppsFlyerLib/AppsFlyerLib.h> in my AppDelegate.h but i see an error 'AppsFlyerLib/AppsFlyerLib.h' file not found. The weird thing is that the error goes away when i run the project and seems that it starts without any errors. startWithCompletionHandler correctly returns with no error. Is this some kind of bug? Anyone else experienced this behaviour? I am in xcode 13.3.1 and AppsFlyerFramework 6.5.2 . Any help or suggestion appreciated!
[[AppsFlyerLib shared] startWithCompletionHandler:^(NSDictionary<NSString *,id> *dictionary, NSError *error) {
if (error) {
NSLog(#"%#", error);
return;
}
if (dictionary) {
NSLog(#"%#", dictionary);
return;
}
}];

CallDirectory Extension beginRequestWithExtensionContext not called

I'm trying to add the CallDirectory extension to enable the call identification based on the contacts available in my app.
I have enabled the permissions under Call settings.
But beginRequestWithExtensionContext is not called even when the device receives the call.
beginRequestWithExtensionContext is in the subclass of CXCallDirectoryProvider which conforms to CXCallDirectoryExtensionContextDelegate
The documentation says:
You set up both identification and blocking of incoming calls in the
implementation of the beginRequest(with:) method of the
CXCallDirectoryProvider subclass of your Call Directory extension.
This method is called when the system launches the app extension.
When does the system launches the app extension ?
I setup it as following in my delegate:
[[CXCallDirectoryManager sharedInstance] getEnabledStatusForExtensionWithIdentifier:#"com.x.CallerID" completionHandler:^(CXCallDirectoryEnabledStatus enabledStatus, NSError * _Nullable error) {
if (enabledStatus == 0) {
// NSLog(#"Code 0 tells you that there's an error. Common is that the identifierString is wrong.");
} else if (enabledStatus == 1) {
DDLogDebug(#"%#",#"CallerID - Code 1 is deactivated extension");
[self enableCallerIdAlert];
} else if (enabledStatus == 2) {
DDLogDebug(#"%#",#"CallerID - Code 2 is an activated extension");
}
}];
[[CXCallDirectoryManager sharedInstance] reloadExtensionWithIdentifier:#"com.x.CallerID" completionHandler:^(NSError *error){
if(error) {
NSLog(#"CallerID - refresh failed. error is %#",[error description]);
}
//your completetion
}];
CallDirectoryHAndler.m:
- (void)beginRequestWithExtensionContext:(CXCallDirectoryExtensionContext *)context
{
[super beginRequestWithExtensionContext:context];
context.delegate = self;
//phoneNumber , label are dummy
[context addIdentificationEntryWithNextSequentialPhoneNumber:phoneNumber label:label];
[context completeRequestWithCompletionHandler:nil];
}
Could someone please point out What I'm missing here?

Unable to launch twitter api in my iOS program, error with Fabric

I recently tried to implement twitter login with my app, using Fabric.
While following their tutorial, I made a little change - instead of defining the TWTRLogInButton in my .m file, I defined it in my .h file first.
So in my .h file, I set the button like:
#property (strong, nonatomic) IBOutlet TWTRLogInButton *twitterButton;
And in my .m file the code is:
_twitterButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
if (session) {
NSLog(#"signed in as %#", [session userName]);
} else {
NSLog(#"error: %#", [error localizedDescription]);
}
}];
And it gives me an error like this:
"[Fabric] Unable to locate application icon"
And ever since I can't find a way to solve this.
I have tried changing the code exactly just as tutorial said as well, but it did not work either. I simply don't understand why Fabric is unable to locate my icon...
Any help is appreciated. Thank you in advance.

openParentApplication:reply: error with asynchronous network call in containing app

I'm getting stuck with an error when using my Watchkit Application. When I launch it, I ask the containing iOS app to get some data from network. The problem is that I get an error saying the containing app never calls 'reply()' :o But looking at my code, it should call it.
I tried to debug every step from openParentApplication to the 'reply()' call, and it seems to work well =X
Here is my code in the Watchkit extension
- (void)initDiaporamasWithSuccess:(void (^)())success andFailure:(void (^)(NSError*))failure {
NSLog(#"Ask to load diapos");
__weak typeof(self) weakSelf = self;
[WKInterfaceController openParentApplication:#{#"watchKit": #"watchKit.initDiapos"} reply:^(NSDictionary *replyInfo, NSError *error) {
if (error) {
NSLog(#"%#", error);
if (failure) {
failure(error);
}
return;
}
NSLog(#"got items : %#", replyInfo[#"diapos"]);
weakSelf.diaporamas = replyInfo[#"diapos"];
[weakSelf setDiaporama:replyInfo[#"firstDiapo"] AtIndex:0];
if (success) {
success();
}
}];
}
The result should be an NSDictionary containing an NSArray with some diaporamas basic informations, and an object (Diapo) containing the full informations of the first diaporama (e.g. self.diaporamas[0])
And here is the code in the containing app's AppDelegate :
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {
// Maybe we could handle multiple watchKit extension calls that way ?
// Something like a key-value 'protocol' to run the right block of code
NSString *watchKitCall = userInfo[#"watchKit"];
NSLog(#"watchKit handled");
if ([watchKitCall isEqualToString:#"watchKit.initDiapos"]) {
[AppDelegate watchInitialObjects:^(NSDictionary *info) {
NSLog(#"Managed to get initial infos");
reply(info);
} failure:^(NSError *error) {
NSLog(#"Fail : %#", error);
reply(#{#"error": error});
}];
}
}
+ (void) watchInitialObjects:(void (^)(NSDictionary *info))success failure:(void (^)(NSError *error))failure {
NSDictionary *parameters = #{#"site" : #(14), #"limit" : #(10)};
[AppDelegate requestDiapoListWithParams:parameters success:^(NSArray *items) {
if ([items count] == 0)
{
NSError *error = [NSError errorWithDomain:#"com.domain.app" code:404 userInfo:nil];
failure(error);
return;
}
Diapo *firstDiapo = [items firstObject];
[AppDelegate requestDiapoDetailWithDiapo:firstDiapo success:^(Diapo *diapo) {
if (!diapo)
{
NSError *error = [NSError errorWithDomain:#"com.domain.app" code:404 userInfo:nil];
failure(error);
return;
}
NSDictionary *result = #{
#"firstDiapo" : diapo,
#"diapos" : items
};
success(result);
} failure:^(NSError *error) {
failure(error);
}];
} failure:^(NSError *error) {
failure(error);
}];
}
In the watchKitHandler, I call watchInitialObjects to get the diaporamas array and the first diaporama's informations.
In the watchInitialObjects, I make a first network call to get the array, and on success, I make an other network call to get the firs diaporama informations.
To make the calls and map the JSON into objects, I use RESTKit
I really don't get what could be the error =x
UPDATE
I forgot to write the error I get, here it is :
Error Domain=com.apple.watchkit.errors Code=2 "The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]" UserInfo=0x7fcb53e12830 {NSLocalizedDescription=The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]}
And I kept trying to know why I get this error, and I think I found it:
It seems that there is a (very little) timeout to do the work in the containing app. But I mapped the JSON data I received directly in the containing app and then, send those custom objects in the reply(). But when I removed the mapping part, it worked well !
So...that's why I think that was the problem =X
Does anybody could approve my thoughts or corrects me ?
After hours of searching and testing different codes, I finally found my problem...and it's obvious when we read the Apple documentation about 'application:handleWatchKitExtensionRequest:reply:' seriously...
here is the answer : (it's in the documentation)
The contents of the dictionary must be serializable to a property list file.
Which means that objects can ONLY be dictionaries, arrays, strings, numbers (integer and float), dates, binary data, or Boolean values
...I feel dumb ><

GKAchievement reportAchievements:withCompletionHandler: crash

Everyone once in a while I will get crash reports for my App (via crittercism) with the following NSInvalidArgumentException crash:
+[GKAchievement reportAchievements:withCompletionHandler:]: unrecognized selector sent to class 0x3f940a84
The code looks like this:
NSMutableArray *achivementArray = [NSMutableArray arrayWithCapacity:20];
for (NSString *achievementID in achievementsToUpload) // achievementsToUpload is a NSSet
{
GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier:achievementID];
if (achievement)
{
...
[achivementArray addObject:achievement];
}
}
[GKAchievement reportAchievements:achivementArray withCompletionHandler:^(NSError *error)
{
if (error != nil)
{
NSLog(#"Error sending achievement: %#", error.localizedDescription);
}
}];
If the error is indeed inside reportAchievements:withCompletionHandler:, as far as I can see, the source of the error can come from two places: 1) achivementArray is not an NSArray or 2) error is not really an NSError.
In the case of #1, I create the array a few lines above the call and in case #2, I doubt the OS is sending back a non-NSError object.
Any ideas?
Header looks like:
+ (void)reportAchievements:(NSArray *)achievements withCompletionHandler:(void(^)(NSError *error))completionHandler __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
So the issue may be in base sdk that you are using. This method is available starting from iOS 6.0.
Hope it will be helpful

Resources