How to receive message in wechat itegrated in ios? - ios

I have integrate wechat sdk in iphone app. I can send a message with using SendMessageToWXReq class. But How i should receive the message within the my app.How GetMessageFromWXReq and ShowMessageFromWXReq works? Please provide me sample code.

onResp not called.
AppDelegate.m
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [WXApi handleOpenURL:url delegate:self];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [WXApi handleOpenURL:url delegate:self];
}
Here,if you set delegate to self ,you will get onResp called in AppDelegate.m
If you set delegate to some other viewController instance, you will get onResp called in viewController.m
If this helps you, please let me know.

Related

How to handle the url when app is launched?

How to handle the deep link in iOS objective c when the app is suspended. If the app is in the background open url delegate will be calling so can handle the url there.
In which delegate method can handle the url when the app is launched from a deep link with custom url scheme and parameters.
Url is something like myapp://params?app_id=1234
Thanks in advance.
I have implemented Firebase Dynamic Link in my project(Similar to deferred links from Facebook) and the following delegate helps to handle Universal Dynamic Links :
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:
#if defined(__IPHONE_12_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0)
(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler {
#else
(nonnull void (^)(NSArray *_Nullable))restorationHandler {
}
NSUserActivity Object will contain "webpageURL" that you are looking for.
Further, you can look for the below discussion to solve this :
Firebase Deeplink not calling application:continueUserActivity:restorationHandler function of AppDelegate in Swift 3
I suspect your main logic expects - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options to be called.
I also suspect in your case it does not get called if the app has been killed.
The solution is simple - make sure you have both - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions and - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions and that they both return YES.
This will make iOS call - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options on app launch.

PFLogInViewController/Facebook not working

Using a PFLogInViewController subclass in my app to allow users to login with Facebook, I have an issue.
While it works perfectly in some cases; in other cases it doesn’t.
After I give permissions to the user the “Loading…” spinning wheel comes up and stays there for ever.
And some times it works but the waiting time (with the spinning wheel) is a bit long.
Though I now have quite a bit of experience with Parse.com, this is the first time I try to integrate Facebook login, therefore I may well be doing something the wrong way.
Here is some of the code I use related to this:
In the AppDelegate.m I do:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
……
[PFFacebookUtils initializeFacebook];
……
return YES;
}
and:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
BOOL fbAppCallStatus = [FBAppCall handleOpenURL: url
sourceApplication: sourceApplication
withSession: [PFFacebookUtils session]];
return fbAppCallStatus;
}
In the CustomLogInViewController.m I do:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([PFUser currentUser]) [self quitView];
}
Let me know if there seem to be an obvious mistake here.
Thanks for any tip.

Launch app from URL issue

I'm trying to launch my app using URL from Safari.
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(#"Launched with URL");
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(#"Launched normally");
// Override point for customization after application launch.
return YES;
}
(Also tried -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
)
If the app is in the background (i.e, if I double click the home button, it's there) the app launches correctly and console shows Launched with URL.
However, if I close it completely, meaning, double clicking home button, holding the app and clicking the minus sign, when trying to launch it again via Safari, it just shows a black screen and logs nothing to console.
This happens both on the device and simulator (5.1 both)
Is there another delegate which should be called when the app is completely closed?
Thanks!
If your application is opening from Safari, this means you have implemented the URL schema correctly.
Handle the Opened URl in these application delegate events
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:
(NSString *)sourceApplication
annotation:(id)annotation
{
}
Just Make sure you have properly encoded your URL it might be the case that your URL is breaking.

IOS5 Facebook integration - fbDidLogin is not called

I've been spending days on doing a simple Facebook post through an app. I used this tutorial and found out that fbDidLogin is not called. As I've been looking for solutions, I've found out that this is a way to make the fbDidLogin be called.
Enlighten me as to what I may be missing out.
Attached here is the essential methods for FB integration in my app delegate.
App delegate.m
#synthesize window = _window;
#synthesize wallSnapVC = _wallSnapVC;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.wallSnapVC = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:#"wallSnapViewController"];
self.window.rootViewController = self.wallSnapVC;
[self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
return [[_wallSnapVC facebook] handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [[_wallSnapVC facebook] handleOpenURL:url];
}

Is it possible to receive URL data without adding callbacks in the UIApplicationDelegate?

I'm writing a shared manager class. It knows to start and stop some services by listening for the UIApplicationDidBecomeActiveNotification and similar. It's also supposed to do is to handle a certain set of URLs. At the moment, I'm getting it to do that by adding code to the UIApplicationDelegate in each of our apps like so:
#pragma mark - URL support
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
return [[SGBMyManager sharedManager] handleOpenURL:url];
}
// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [[SGBMyManager sharedManager] handleOpenURL:url];
}
That works, but it's not very DRY. I'd like to only have to code this once, in my shared manager class. Is there a UIApplicationDidHandleOpenURL notification or similar that I could listen for?

Resources