Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMPhobos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMPhobos
Commits
efbbe85b
Commit
efbbe85b
authored
Mar 31, 2018
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级GMCache
parent
a10ace42
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
34 deletions
+34
-34
GMViewController.m
Example/GMPhobos/GMViewController.m
+0
-1
Podfile
Example/Podfile
+3
-1
Podfile.lock
Example/Podfile.lock
+8
-7
Phobos.m
Pod/Classes/Phobos.m
+21
-22
README.md
README.md
+2
-3
No files found.
Example/GMPhobos/GMViewController.m
View file @
efbbe85b
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
[
Phobos
sharedClient
].
serverAPI
=
url
;
[
Phobos
sharedClient
].
serverAPI
=
url
;
}
}
-
(
void
)
didReceiveMemoryWarning
-
(
void
)
didReceiveMemoryWarning
{
{
[
super
didReceiveMemoryWarning
];
[
super
didReceiveMemoryWarning
];
...
...
Example/Podfile
View file @
efbbe85b
source
'https://github.com/CocoaPods/Specs.git'
source
'git@git.wanmeizhensuo.com:gengmeiios/GMSpecs.git'
source
'git@git.wanmeizhensuo.com:gengmeiios/GMSpecs.git'
source
'https://github.com/CocoaPods/Specs.git'
platform
:ios
,
'8.0'
platform
:ios
,
'8.0'
use_frameworks!
use_frameworks!
inhibit_all_warnings!
inhibit_all_warnings!
...
@@ -7,6 +8,7 @@ inhibit_all_warnings!
...
@@ -7,6 +8,7 @@ inhibit_all_warnings!
target
'GMPhobos_Example'
do
target
'GMPhobos_Example'
do
pod
'GMPhobos'
,
:path
=>
'../'
pod
'GMPhobos'
,
:path
=>
'../'
pod
'GMCache'
,
'0.2.0'
target
'GMPhobos_Tests'
do
target
'GMPhobos_Tests'
do
inherit!
:search_paths
inherit!
:search_paths
end
end
...
...
Example/Podfile.lock
View file @
efbbe85b
PODS:
PODS:
- GMCache (0.
1.2
):
- GMCache (0.
2.0
):
- TMCache (
~>
2.1.0)
- TMCache (
=
2.1.0)
- GMKit (0.8.4):
- GMKit (0.8.4):
- GMKit/Category (= 0.8.4)
- GMKit/Category (= 0.8.4)
- GMKit/Color (= 0.8.4)
- GMKit/Color (= 0.8.4)
...
@@ -35,7 +35,7 @@ PODS:
...
@@ -35,7 +35,7 @@ PODS:
- GMKit/Protocol (0.8.4):
- GMKit/Protocol (0.8.4):
- Masonry (= 1.1.0)
- Masonry (= 1.1.0)
- SDWebImage (= 3.7.6)
- SDWebImage (= 3.7.6)
- GMPhobos (0.5.
3
):
- GMPhobos (0.5.
4
):
- GMCache
- GMCache
- GMKit
- GMKit
- Masonry (1.1.0)
- Masonry (1.1.0)
...
@@ -45,6 +45,7 @@ PODS:
...
@@ -45,6 +45,7 @@ PODS:
- TMCache (2.1.0)
- TMCache (2.1.0)
DEPENDENCIES:
DEPENDENCIES:
- GMCache (= 0.2.0)
- GMPhobos (from `../`)
- GMPhobos (from `../`)
EXTERNAL SOURCES:
EXTERNAL SOURCES:
...
@@ -52,13 +53,13 @@ EXTERNAL SOURCES:
...
@@ -52,13 +53,13 @@ EXTERNAL SOURCES:
:path: ../
:path: ../
SPEC CHECKSUMS:
SPEC CHECKSUMS:
GMCache:
fb0af70b420715ef9519487fdd932a357b3cd8d4
GMCache:
b7d48432ee2469eb0c6c86c720a1958bd373187e
GMKit: a30da06b84e5c4a357d427c70d1b5ec672a1f6a1
GMKit: a30da06b84e5c4a357d427c70d1b5ec672a1f6a1
GMPhobos:
a6c7419f4ae91aac3c0520902654e96007bdd0d6
GMPhobos:
9549afe9e949fadc2ac54e4bb26cb4c2519cd417
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM:
393bbb8ecc2aa3d185a0a793d6ba79e491b7ebd
4
PODFILE CHECKSUM:
88bad4cf7811c4caa54519587b95fcc2e18bc40
4
COCOAPODS: 1.
3.1
COCOAPODS: 1.
4.0
Pod/Classes/Phobos.m
View file @
efbbe85b
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
//
//
#import "Phobos.h"
#import "Phobos.h"
#import <GMCache/GMCache-umbrella.h>
#import <AdSupport/AdSupport.h>
#import <AdSupport/AdSupport.h>
#import "PhobosUtil.h"
#import "PhobosUtil.h"
#import "PhobosConfig.h"
#import "PhobosConfig.h"
...
@@ -15,6 +14,7 @@
...
@@ -15,6 +14,7 @@
#import "PhobosUtil.h"
#import "PhobosUtil.h"
#import "PhobosCustomVisibleController.h"
#import "PhobosCustomVisibleController.h"
#import "UIDevice+Resolutions.h"
#import "UIDevice+Resolutions.h"
@import
GMCache
;
static
Phobos
*
sharedClient
=
nil
;
static
Phobos
*
sharedClient
=
nil
;
static
NSString
*
sdkVersion
=
@"110"
;
static
NSString
*
sdkVersion
=
@"110"
;
...
@@ -68,8 +68,7 @@ static NSString *sdkVersion = @"110";
...
@@ -68,8 +68,7 @@ static NSString *sdkVersion = @"110";
* disk下的PhobosHaveOpenApp只要存在,就把他取出来放到document下(注:当不支持7.6.16版本的时候,干掉这个方法)
* disk下的PhobosHaveOpenApp只要存在,就把他取出来放到document下(注:当不支持7.6.16版本的时候,干掉这个方法)
*/
*/
-
(
void
)
synchronizePhobosKey
{
-
(
void
)
synchronizePhobosKey
{
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
if
([
GMCache
fetchObjectAtDiskWithkey
:
PhobosHaveOpenApp
])
{
if
([
cache
fetchObjectAtDiskWithkey
:
PhobosHaveOpenApp
])
{
NSString
*
prefePath
=
[
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
)
objectAtIndex
:
0
];
NSString
*
prefePath
=
[
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
)
objectAtIndex
:
0
];
prefePath
=
[
NSString
stringWithFormat
:
@"%@/com.tumblr.TMDiskCache.WMCacheShared/%@"
,
prefePath
,
PhobosHaveOpenApp
];
prefePath
=
[
NSString
stringWithFormat
:
@"%@/com.tumblr.TMDiskCache.WMCacheShared/%@"
,
prefePath
,
PhobosHaveOpenApp
];
NSURL
*
fileUrl
=
[
NSURL
fileURLWithPathComponents
:@[
prefePath
]];
NSURL
*
fileUrl
=
[
NSURL
fileURLWithPathComponents
:@[
prefePath
]];
...
@@ -106,7 +105,7 @@ static NSString *sdkVersion = @"110";
...
@@ -106,7 +105,7 @@ static NSString *sdkVersion = @"110";
在APP启动、从后台到前台的时候需要记录device_opened埋点
在APP启动、从后台到前台的时候需要记录device_opened埋点
*/
*/
-
(
void
)
handleEventDeviceOpened
{
-
(
void
)
handleEventDeviceOpened
{
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
/** 每次打开APP埋点 **/
/** 每次打开APP埋点 **/
NSDictionary
*
dict
=
@{
@"build_cpu_abi"
:
[
PhobosUtil
currentDeviceCPUType
],
NSDictionary
*
dict
=
@{
@"build_cpu_abi"
:
[
PhobosUtil
currentDeviceCPUType
],
@"cpu_count"
:
[
PhobosUtil
currentDeviceCPUCount
],
@"cpu_count"
:
[
PhobosUtil
currentDeviceCPUCount
],
...
@@ -122,10 +121,10 @@ static NSString *sdkVersion = @"110";
...
@@ -122,10 +121,10 @@ static NSString *sdkVersion = @"110";
/** 第一次打开APP埋点 **/
/** 第一次打开APP埋点 **/
// 当不再支持7.6.15版本时,只保留
// 当不再支持7.6.15版本时,只保留
if
(
!
[
c
ache
fetchObjectAtDucmentPathWithkey
:
PhobosHaveOpenApp
])
{
if
(
!
[
GMC
ache
fetchObjectAtDucmentPathWithkey
:
PhobosHaveOpenApp
])
{
[
Phobos
track
:
@"device_activated"
attributes
:@{}
sendNow
:
YES
];
[
Phobos
track
:
@"device_activated"
attributes
:@{}
sendNow
:
YES
];
[
Phobos
track
:
@"device_activated"
attributes
:@{}
sendNow
:
NO
];
[
Phobos
track
:
@"device_activated"
attributes
:@{}
sendNow
:
NO
];
[
c
ache
storeObjectAtDucmentPathWithkey
:
PhobosHaveOpenApp
object
:
PhobosHaveOpenApp
];
[
GMC
ache
storeObjectAtDucmentPathWithkey
:
PhobosHaveOpenApp
object
:
PhobosHaveOpenApp
];
}
}
}
}
...
@@ -159,8 +158,8 @@ static NSString *sdkVersion = @"110";
...
@@ -159,8 +158,8 @@ static NSString *sdkVersion = @"110";
-
(
void
)
handleSessionStart
{
-
(
void
)
handleSessionStart
{
_serialId
=
0
;
_serialId
=
0
;
_sessionId
=
[[
NSUUID
UUID
]
UUIDString
];
_sessionId
=
[[
NSUUID
UUID
]
UUIDString
];
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
[
c
ache
storeObjectAtDucmentPathWithkey
:
PhobosBeginTime
object
:[
PhobosUtil
currentTime
]];
[
GMC
ache
storeObjectAtDucmentPathWithkey
:
PhobosBeginTime
object
:[
PhobosUtil
currentTime
]];
}
}
/**
/**
...
@@ -205,9 +204,9 @@ static NSString *sdkVersion = @"110";
...
@@ -205,9 +204,9 @@ static NSString *sdkVersion = @"110";
* @since 0.0.1
* @since 0.0.1
*/
*/
-
(
void
)
handleSessionOver
{
-
(
void
)
handleSessionOver
{
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
//进入后台的同时,把记录时间同步到服务端,把已使用时间清空
//进入后台的同时,把记录时间同步到服务端,把已使用时间清空
double
beginTime
=
[[
c
ache
fetchObjectAtDucmentPathWithkey
:
PhobosBeginTime
]
doubleValue
];
double
beginTime
=
[[
GMC
ache
fetchObjectAtDucmentPathWithkey
:
PhobosBeginTime
]
doubleValue
];
if
(
beginTime
==
0
)
{
if
(
beginTime
==
0
)
{
return
;
return
;
}
}
...
@@ -226,7 +225,7 @@ static NSString *sdkVersion = @"110";
...
@@ -226,7 +225,7 @@ static NSString *sdkVersion = @"110";
@"build_model"
:
[
UIDevice
deviceVersion
],
@"build_model"
:
[
UIDevice
deviceVersion
],
};
};
[
Phobos
track
:
@"on_app_session_over"
attributes
:
dict
];
[
Phobos
track
:
@"on_app_session_over"
attributes
:
dict
];
[
c
ache
removeObjectAtDucmentPathWithkey
:
PhobosBeginTime
];
[
GMC
ache
removeObjectAtDucmentPathWithkey
:
PhobosBeginTime
];
//当前session结束之后,把id置为0
//当前session结束之后,把id置为0
_serialId
=
0
;
_serialId
=
0
;
}
}
...
@@ -258,7 +257,7 @@ static NSString *sdkVersion = @"110";
...
@@ -258,7 +257,7 @@ static NSString *sdkVersion = @"110";
+
(
void
)
track
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
+
(
void
)
track
:
(
NSString
*
)
eventId
attributes
:
(
NSDictionary
*
)
attributes
{
[
self
track
:
eventId
attributes
:
attributes
sendNow
:
NO
];
[
self
track
:
eventId
attributes
:
attributes
sendNow
:
NO
];
NSArray
*
array
=
[
[
WMCacheService
sharedInstance
]
fetchObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
//超过一定数量的话,统一发送一次
//超过一定数量的话,统一发送一次
if
(
array
.
count
>
PhobosShardCount
)
{
if
(
array
.
count
>
PhobosShardCount
)
{
[
sharedClient
sendArray
:
array
cleanCacheRightNow
:
YES
];
[
sharedClient
sendArray
:
array
cleanCacheRightNow
:
YES
];
...
@@ -403,14 +402,14 @@ static NSString *sdkVersion = @"110";
...
@@ -403,14 +402,14 @@ static NSString *sdkVersion = @"110";
if
(
_logEnabled
)
{
if
(
_logEnabled
)
{
phobosLog
([
NSString
stringWithFormat
:
@"save dictionary: %@"
,
data
]);
phobosLog
([
NSString
stringWithFormat
:
@"save dictionary: %@"
,
data
]);
}
}
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
NSMutableArray
*
dataArray
=
[
c
ache
fetchObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
NSMutableArray
*
dataArray
=
[
GMC
ache
fetchObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
if
(
dataArray
)
{
if
(
dataArray
)
{
[
dataArray
addObject
:
data
];
[
dataArray
addObject
:
data
];
}
else
{
}
else
{
dataArray
=
[
NSMutableArray
arrayWithObject
:
data
];
dataArray
=
[
NSMutableArray
arrayWithObject
:
data
];
}
}
[
c
ache
storeObjectAtDucmentPathWithkey
:
PhobosCacheKey
object
:
dataArray
];
[
GMC
ache
storeObjectAtDucmentPathWithkey
:
PhobosCacheKey
object
:
dataArray
];
}
}
/**
/**
...
@@ -419,7 +418,7 @@ static NSString *sdkVersion = @"110";
...
@@ -419,7 +418,7 @@ static NSString *sdkVersion = @"110";
* @since 0.0.1
* @since 0.0.1
*/
*/
-
(
void
)
fetchDataAndSend
{
-
(
void
)
fetchDataAndSend
{
NSArray
*
paramsArray
=
[
[
WMCacheService
sharedInstance
]
fetchObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
NSArray
*
paramsArray
=
[
GMCache
fetchObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
if
(
paramsArray
.
count
>
0
)
{
if
(
paramsArray
.
count
>
0
)
{
[
self
sendArray
:
paramsArray
cleanCacheRightNow
:
YES
];
[
self
sendArray
:
paramsArray
cleanCacheRightNow
:
YES
];
}
}
...
@@ -429,7 +428,7 @@ static NSString *sdkVersion = @"110";
...
@@ -429,7 +428,7 @@ static NSString *sdkVersion = @"110";
从缓存区获取数据,发给服务器,请求成功的时候,把缓存区的数据删除掉
从缓存区获取数据,发给服务器,请求成功的时候,把缓存区的数据删除掉
*/
*/
-
(
void
)
sendArray
{
-
(
void
)
sendArray
{
NSMutableArray
*
dataArray
=
[
[
WMCacheService
sharedInstance
]
fetchObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
];
NSMutableArray
*
dataArray
=
[
GMCache
fetchObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
];
if
(
_logEnabled
)
{
if
(
_logEnabled
)
{
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:
dataArray
options
:
NSJSONWritingPrettyPrinted
error
:
nil
];
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:
dataArray
options
:
NSJSONWritingPrettyPrinted
error
:
nil
];
NSString
*
jsonString
=
[[
NSString
alloc
]
initWithData
:
data
encoding
:
NSUTF8StringEncoding
];
NSString
*
jsonString
=
[[
NSString
alloc
]
initWithData
:
data
encoding
:
NSUTF8StringEncoding
];
...
@@ -441,7 +440,7 @@ static NSString *sdkVersion = @"110";
...
@@ -441,7 +440,7 @@ static NSString *sdkVersion = @"110";
if
(
compressedData
)
{
if
(
compressedData
)
{
[
PhobosUtil
sendData
:
compressedData
success
:
^
(
NSInteger
code
)
{
[
PhobosUtil
sendData
:
compressedData
success
:
^
(
NSInteger
code
)
{
phobosLog
(
@"✈ ---------- ✈ data arrived Mars"
);
phobosLog
(
@"✈ ---------- ✈ data arrived Mars"
);
[
[
WMCacheService
sharedInstance
]
removeObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
];
[
GMCache
removeObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
];
}];
}];
}
}
}
}
...
@@ -460,18 +459,18 @@ static NSString *sdkVersion = @"110";
...
@@ -460,18 +459,18 @@ static NSString *sdkVersion = @"110";
-
(
void
)
sendArray
:
(
NSArray
*
)
array
cleanCacheRightNow
:
(
BOOL
)
clean
{
-
(
void
)
sendArray
:
(
NSArray
*
)
array
cleanCacheRightNow
:
(
BOOL
)
clean
{
@try
{
@try
{
//1.获取缓存区的数据,把新数据追加进去
//1.获取缓存区的数据,把新数据追加进去
WMCacheService
*
cache
=
[
WMCacheService
sharedInstance
];
NSMutableArray
*
dataArray
=
[
c
ache
fetchObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
];
NSMutableArray
*
dataArray
=
[
GMC
ache
fetchObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
];
if
(
dataArray
)
{
if
(
dataArray
)
{
[
dataArray
addObjectsFromArray
:
array
];
[
dataArray
addObjectsFromArray
:
array
];
}
else
{
}
else
{
dataArray
=
[
NSMutableArray
arrayWithArray
:
array
];
dataArray
=
[
NSMutableArray
arrayWithArray
:
array
];
}
}
[
c
ache
storeObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
object
:
dataArray
];
[
GMC
ache
storeObjectAtDucmentPathWithkey
:
PhobosTempCacheKey
object
:
dataArray
];
//2.把缓存区的数据发送给服务器
//2.把缓存区的数据发送给服务器
[
self
sendArray
];
[
self
sendArray
];
//3.把原有的数据删除
//3.把原有的数据删除
[
c
ache
removeObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
[
GMC
ache
removeObjectAtDucmentPathWithkey
:
PhobosCacheKey
];
}
}
@catch
(
NSException
*
exception
)
{
@catch
(
NSException
*
exception
)
{
phobosLog
(
exception
);
phobosLog
(
exception
);
...
...
README.md
View file @
efbbe85b
...
@@ -53,7 +53,7 @@ WMUser *user = [[WMLoginManager shareInstance] user];
...
@@ -53,7 +53,7 @@ WMUser *user = [[WMLoginManager shareInstance] user];
```
```
If you would like to use Phobos, you must set the currentCityId that is used with the -
[
setCurrentCityId:
]
Instance method.
If you would like to use Phobos, you must set the currentCityId that is used with the -
[
setCurrentCityId:
]
Instance method.
```
objc
```
objc
WMCityObject
*
city
=
[
[
WMCacheService
sharedInstance
]
fetchObjectAtDucmentPathWithkey
:
kCurrentCity
];
WMCityObject
*
city
=
[
GMCache
fetchObjectAtDucmentPathWithkey
:
kCurrentCity
];
if
(
city
)
{
if
(
city
)
{
[
client
setCurrentCityId
:
city
.
id
];
[
client
setCurrentCityId
:
city
.
id
];
}
}
...
@@ -81,4 +81,4 @@ Guojun Zhai and Thierry Xing
...
@@ -81,4 +81,4 @@ Guojun Zhai and Thierry Xing
## License
## License
GMPhobos is available under the MIT license. See the LICENSE file for more info.
GMPhobos is available under the MIT license. See the LICENSE file for more info.
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment