Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[iOS] Add last page info. #2918

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ typedef enum : NSUInteger {
*/
- (void)setViewportWidth:(CGFloat)width;

/**
* @abstract Get information about the last rendered page.
Useful fot debugging and fixing online bugs.
*/
+ (NSDictionary*)lastPageInfo;

/**
* Deprecated
*/
Expand Down
21 changes: 21 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@

NSTimeInterval JSLibInitTime = 0;

static NSString* lastPageInfoLock = @"";
static NSDictionary* lastPageInfo = nil;

typedef enum : NSUInteger {
WXLoadTypeNormal,
WXLoadTypeBack,
Expand Down Expand Up @@ -316,6 +319,11 @@ - (void)renderWithURL:(NSURL *)url options:(NSDictionary *)options data:(id)data
return;
}
WXLogInfo(@"pageid: %@ renderWithURL: %@", _instanceId, url.absoluteString);

@synchronized (lastPageInfoLock) {
lastPageInfo = @{@"pageId": [_instanceId copy], @"url": [url absoluteString] ?: @""};
}

[WXCoreBridge install];
if (_useBackupJsThread) {
[[WXSDKManager bridgeMgr] executeJSTaskQueue];
Expand All @@ -339,6 +347,10 @@ - (void)renderView:(id)source options:(NSDictionary *)options data:(id)data
_options = [options isKindOfClass:[NSDictionary class]] ? options : nil;
_jsData = data;
WXLogInfo(@"pageid: %@ renderView pageNmae: %@ options: %@", _instanceId, _pageName, options);

@synchronized (lastPageInfoLock) {
lastPageInfo = @{@"pageId": [_instanceId copy], @"options": options ? [options description] : @""};
}

[WXCoreBridge install];
if (_useBackupJsThread) {
Expand Down Expand Up @@ -1141,6 +1153,15 @@ - (void)didDisappear
}
}

+ (NSDictionary*)lastPageInfo
{
NSDictionary* result;
@synchronized (lastPageInfoLock) {
result = [lastPageInfo copy];
}
return result;
}

@end

@implementation WXSDKInstance (Deprecated)
Expand Down