Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2022-11-23 13:28:26 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5569bbe8f6836bf8d75deaf1a4b0c797ba616d1c
5569bbe8
1 parent
e6360973
dynamic initialisation, fix checkforLoyaltySDK
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
12 deletions
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
SwiftWarplyFramework/SwiftWarplyFramework/Warply/managers/WLPushManager.h
SwiftWarplyFramework/SwiftWarplyFramework/Warply/managers/WLPushManager.m
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
View file @
5569bbe
...
...
@@ -101,7 +101,8 @@
-
(
void
)
getMultilingualMerchantsAsync
:(
NSArray
*
)
categories
andDefaultShown
:(
NSNumber
*
)
defaultShown
andCenter
:(
NSNumber
*
)
center
andTags
:(
NSArray
*
)
tags
andUuid
:(
NSString
*
)
uuid
andDistance
:(
NSNumber
*
)
distance
parent_uuids
:(
NSArray
*
)
parent_uuids
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
// - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
-
(
void
)
didReceiveNotification
:(
NSDictionary
*
)
payload
;
-
(
NSNumber
*
)
checkforLoyaltySDKNotification
:(
NSDictionary
*
)
payload
;
-
(
BOOL
)
checkforLoyaltySDKNotification
:(
NSDictionary
*
)
payload
;
//- (NSNumber*)checkforLoyaltySDKNotification:(NSDictionary *)payload;
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload whileAppWasInState:(UIApplicationState)appState;
// TEST CODE FOR PUSH
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
View file @
5569bbe
...
...
@@ -1693,17 +1693,28 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
-
(
void
)
didReceiveNotification
:
(
NSDictionary
*
)
payload
{
if
([
Warply
sharedServiceExists
]
==
YES
)
{
[[
Warply
sharedService
].
pushManager
didReceiveRemoteNotification
:
payload
whileAppWasInState
:
WLApplicationStateClosed
];
// [[Warply sharedService].pushManager didReceiveRemoteNotification:payload whileAppWasInState:WLApplicationStateClosed];
[[
Warply
sharedService
].
pushManager
didReceiveNotificationPM
:
payload
];
}
}
// - (BOOL)checkForLoyaltySDKNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state {
-
(
NSNumber
*
)
checkforLoyaltySDKNotification
:
(
NSDictionary
*
)
payload
{
//- (NSNumber*)checkforLoyaltySDKNotification:(NSDictionary *)payload {
//
// if ([Warply sharedServiceExists] == YES) {
// return [[Warply sharedService].pushManager checkforLoyaltySDKNotificationPM:payload] ? @1 : @0;
// } else {
// return nil;
// }
//}
-
(
BOOL
)
checkforLoyaltySDKNotification
:
(
NSDictionary
*
)
payload
{
if
([
Warply
sharedServiceExists
]
==
YES
)
{
return
[[
Warply
sharedService
].
pushManager
checkforLoyaltySDKNotificationPM
:
payload
]
?
@1
:
@0
;
if
([
payload
valueForKey
:
@"_a"
]
==
nil
)
{
// The push was sent from another push service
return
NO
;
}
else
{
return
nil
;
return
YES
;
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/managers/WLPushManager.h
View file @
5569bbe
...
...
@@ -161,6 +161,8 @@ typedef enum WLApplicationState : unsigned int{
*/
-
(
void
)
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
whileAppWasInState
:(
WLApplicationState
)
state
;
-
(
void
)
didReceiveNotificationPM
:(
NSDictionary
*
)
userInfo
;
-
(
BOOL
)
checkforLoyaltySDKNotificationPM
:(
NSDictionary
*
)
userInfo
;
// TEST CODE FOR PUSH
// - (BOOL)checkforLoyaltySDKNotificationPM:(NSDictionary *)userInfo whileAppWasInState:(UIApplicationState)appState;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/managers/WLPushManager.m
View file @
5569bbe
...
...
@@ -303,6 +303,90 @@ static const char* jailbreak_apps[] =
}
///////////////////////////////////////////////////////////////////////////////
//- (BOOL)didReceiveNotificationPM:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state
-
(
void
)
didReceiveNotificationPM
:
(
NSDictionary
*
)
userInfo
{
// TODO: Check if this guard should be commented
if
([
userInfo
valueForKey
:
@"_a"
]
==
nil
)
{
// The push was sent from another push service
return
;
}
// TODO: Check if states are correct, especially from didFinishLaunchingWithOptions
WLApplicationState
state
;
if
([
UIApplication
sharedApplication
].
applicationState
==
UIApplicationStateActive
)
state
=
WLApplicationStateActive
;
else
if
([
UIApplication
sharedApplication
].
applicationState
==
UIApplicationStateInactive
)
state
=
WLApplicationStateClosed
;
else
state
=
WLApplicationStateBackground
;
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
userInfo
options
:
NSJSONWritingPrettyPrinted
error
:
nil
];
NSString
*
jsonString
=
[[
NSString
alloc
]
initWithData
:
jsonData
encoding
:
NSUTF8StringEncoding
];
WLLOG
(
@"Did receive push: %@"
,
jsonString
);
WLInboxItem
*
inboxItem
=
[[
WLInboxItem
alloc
]
initWithAttributes
:
userInfo
]
;
// [WLAnalyticsManager logUserReceivedPush:inboxItem];
if
(
state
!=
WLApplicationStateActive
)
{
[
WLAnalyticsManager
logUserEngagedPush
:
inboxItem
];
}
if
(
inboxItem
.
action
!=
0
)
{
[
self
.
customPushHanlder
didReceiveRemoteNotification
:
userInfo
whileAppWasInState
:
state
];
return
;
}
switch
(
state
)
{
case
WLApplicationStateActive
:
{
UIAlertController
*
alert
=
[
UIAlertController
alertControllerWithTitle
:[[
userInfo
objectForKey
:
@"aps"
]
objectForKey
:
@"alert"
]
message
:
@""
preferredStyle
:
UIAlertControllerStyleAlert
];
UIAlertAction
*
yesButton
=
[
UIAlertAction
actionWithTitle
:
NSLocalizedString
(
@"Close"
,
@"Warply"
)
style
:
UIAlertActionStyleDefault
handler
:^
(
UIAlertAction
*
action
)
{
//Handle your yes please button action here
}];
UIAlertAction
*
noButton
=
[
UIAlertAction
actionWithTitle
:
NSLocalizedString
(
@"View"
,
@"Warply"
)
style
:
UIAlertActionStyleDefault
handler
:^
(
UIAlertAction
*
action
)
{
//Handle no, thanks button
}];
[
alert
addAction
:
yesButton
];
[
alert
addAction
:
noButton
];
UIWindow
*
alertWindow
=
[[
UIWindow
alloc
]
initWithFrame
:[
UIScreen
mainScreen
].
bounds
];
alertWindow
.
rootViewController
=
[[
UIViewController
alloc
]
init
];
alertWindow
.
windowLevel
=
UIWindowLevelAlert
+
1
;
[
alertWindow
makeKeyAndVisible
];
[
alertWindow
.
rootViewController
presentViewController
:
alert
animated
:
YES
completion
:
nil
];
// UIAlertView *alert = [[UIAlertView alloc] init];
// [alert setTitle:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]];
// [alert addButtonWithTitle:NSLocalizedString(@"Close", @"Warply")];
// [alert addButtonWithTitle:NSLocalizedString(@"View", @"Warply")];
// [alert setDelegate:self];
// [alert show];
self
.
pendingItem
=
inboxItem
;
break
;
}
case
WLApplicationStateBackground
:
{
[
self
showItem
:
inboxItem
];
break
;
}
case
WLApplicationStateClosed
:
self
.
pendingItem
=
inboxItem
;
break
;
}
return
;
}
///////////////////////////////////////////////////////////////////////////////
//- (BOOL)checkForLoyaltySDKNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state
-
(
BOOL
)
checkforLoyaltySDKNotificationPM
:
(
NSDictionary
*
)
userInfo
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
5569bbe
...
...
@@ -80,6 +80,22 @@ public class swiftApi {
UserDefaults
.
standard
.
set
(
newValue
,
forKey
:
"trackersEnabled"
)
}
public
func
getAppUuid
()
->
String
{
return
UserDefaults
.
standard
.
string
(
forKey
:
"appUuidUD"
)
??
""
}
public
func
setAppUuid
(
_
newUserTag
:
String
)
->
Void
{
UserDefaults
.
standard
.
set
(
newUserTag
,
forKey
:
"appUuidUD"
)
}
public
func
getMerchantId
()
->
String
{
return
UserDefaults
.
standard
.
string
(
forKey
:
"merchantIdUD"
)
??
""
}
public
func
setMerchantId
(
_
newUserTag
:
String
)
->
Void
{
UserDefaults
.
standard
.
set
(
newUserTag
,
forKey
:
"merchantIdUD"
)
}
public
func
getStepsWebview
()
->
Int
{
return
GlobalVariables
.
stepsWebview
}
...
...
@@ -6189,17 +6205,48 @@ public class swiftApi {
public
func
didReceiveNotification
(
_
payload
:
[
String
:
Any
])
->
Void
{
let
instanceOfMyApi
=
MyApi
()
instanceOfMyApi
.
didReceiveNotification
(
payload
)
let
isInitialised
=
instanceOfMyApi
.
sdkInitialised
();
if
(
isInitialised
==
true
)
{
instanceOfMyApi
.
didReceiveNotification
(
payload
)
}
else
{
let
appUuid
=
swiftApi
()
.
getAppUuid
()
let
merchantId
=
swiftApi
()
.
getMerchantId
()
instanceOfMyApi
.
initialize
(
withCallback
:
nil
,
uuid
:
appUuid
,
merchantId
:
merchantId
,
lang
:
"el"
,
successBlock
:
initializeCallback
,
failureBlock
:
initializeFailureCallback
)
}
func
initializeCallback
(
_
initializeData
:
[
AnyHashable
:
Any
]?)
->
Void
{
if
((
initializeData
?[
"status"
]
as?
Int
)
==
1
)
{
instanceOfMyApi
.
didReceiveNotification
(
payload
)
}
}
func
initializeFailureCallback
(
_
error
:
Error
?)
->
Void
{
}
}
public
func
checkForLoyaltySDKNotification
(
_
payload
:
[
String
:
Any
])
->
Bool
?
{
public
func
checkForLoyaltySDKNotification
(
_
payload
:
[
String
:
Any
])
->
Bool
{
let
instanceOfMyApi
=
MyApi
()
return
instanceOfMyApi
.
checkforLoyaltySDKNotification
(
payload
)
as?
Bool
let
isSDKPush
=
instanceOfMyApi
.
checkforLoyaltySDKNotification
(
payload
)
if
(
isSDKPush
==
false
)
{
return
false
;
}
else
{
swiftApi
()
.
didReceiveNotification
(
payload
)
return
true
;
}
}
// public func checkForLoyaltySDKNotification(_ payload: [String : Any]) -> Bool? {
// let instanceOfMyApi = MyApi()
// return instanceOfMyApi.checkforLoyaltySDKNotification(payload) as? Bool
// }
// TEST CODE FOR PUSH
// public func checkForLoyaltySDKNotification(_ payload: [String : Any], _ appState: UIApplication.State) -> Bool {
...
...
@@ -6266,7 +6313,9 @@ public class swiftApi {
if
(
isInitialised
==
true
)
{
instanceOfMyApi
.
sendDeviceInfoIfNecessary
(
newDeviceToken
)
}
else
{
instanceOfMyApi
.
initialize
(
withCallback
:
nil
,
uuid
:
"0086a2088301440792091b9f814c2267"
,
merchantId
:
"58763"
,
lang
:
"el"
,
successBlock
:
initializeCallback
,
failureBlock
:
initializeFailureCallback
)
let
appUuid
=
swiftApi
()
.
getAppUuid
()
let
merchantId
=
swiftApi
()
.
getMerchantId
()
instanceOfMyApi
.
initialize
(
withCallback
:
nil
,
uuid
:
appUuid
,
merchantId
:
merchantId
,
lang
:
"el"
,
successBlock
:
initializeCallback
,
failureBlock
:
initializeFailureCallback
)
}
...
...
@@ -6454,4 +6503,20 @@ public class swiftApi {
}
public
func
getIsDevEnvironment
(
_
isDevEnv
:
Bool
)
->
Void
{
// PROD app: 0086a2088301440792091b9f814c2267
// DEV app: f83dfde1145e4c2da69793abb2f579af
// PROD merchantId: 58763
// DEV merchantId: 20113
if
(
isDevEnv
==
true
)
{
swiftApi
()
.
setAppUuid
(
"f83dfde1145e4c2da69793abb2f579af"
)
swiftApi
()
.
setMerchantId
(
"20113"
)
}
else
{
swiftApi
()
.
setAppUuid
(
"0086a2088301440792091b9f814c2267"
)
swiftApi
()
.
setMerchantId
(
"58763"
)
}
}
}
...
...
Please
register
or
login
to post a comment