PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile (précédentes versions) → Xcode 8 ios 10 push windev 20
Xcode 8 ios 10 push windev 20
Débuté par arempenaux, 21 juin 2017 19:53 - Aucune réponse
Membre enregistré
29 messages
Posté le 21 juin 2017 - 19:53
Pour tout ceux qui on windev mobile 20 je vous joint 2 patch le premier pour xcode8 pour acce au photo et appareil photo le deuxieme pour la compatibilité des notification push avec IOS 10

code a ajouter dans votre fichier info.pliste

<key>NSCameraUsageDescription</key>
<string>photo de profil pour afficher dans le repertoire</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo de profil pour afficher dans le repertoir</string>


et la remplacer les fichier WDAppDelegate.h avec ça

//
// WDAppDelegate.h
//

#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>

@interface WDAppDelegate : NSObject <UIApplicationDelegate,UNUserNotificationCenterDelegate> {
UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end


et celui la pour WDAppDelegate.mm

//
// WDAppDelegate.mm
//
//

#import "WDAppDelegate.h"
// definition de la constante version ios 10 9 8 7 ....
#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

void InitAppLaunchOptions(NSDictionary *pclDic);
void InitInstance();
void InitModule(const struct _stMyModuleInfo* pstModule);
void LoadWDLFile(NSString*);
void InitExec();
void TermExec();
void InitInternalLanguage(int);
void ExecDidEnterBackground();
void ExecWillEnterForeground();
extern const struct _stMyModuleInfo gstMyModuleInfo1;
void OBJ_InitIOS(UIWindow *pclWindow, BOOL moveControls);
void OBJ_SendApplicationWillResignActive(void);
void OBJ_SendApplicationDidBecomeActive(void);
extern const struct _stMyModuleInfo gstMyModuleInfo3;
extern const struct _stMyModuleInfo gstMyModuleInfo4;
extern const struct _stMyModuleInfo gstMyModuleInfo6;
extern const struct _stMyModuleInfo gstMyModuleInfo7;
extern const struct _stMyModuleInfo gstMyModuleInfo8;
extern const struct _stMyModuleInfo gstMyModuleInfo9;
extern const struct _stMyModuleInfo gstMyModuleInfo10;
extern const struct _stMyModuleInfo gstMyModuleInfo21;
extern const struct _stMyModuleInfo gstMyModuleInfo28;
extern const struct _stMyModuleInfo gstMyModuleInfo37;
extern const struct _stMyModuleInfo gstMyModuleInfo42;
extern const struct _stMyModuleInfo gstMyModuleInfo61;
extern const struct _stMyModuleInfo gstMyModuleInfo68;
extern const struct _stMyModuleInfo gstMyModuleInfo69;
void DEVICE_HandleNotification(UILocalNotification *pclNotif);
void DEVICE_HandlePushNotificationRegistration(NSData *deviceToken);
void DEVICE_HandlePushNotificationRegistrationError(NSError *error);
void DEVICE_HandlePushNotification(NSDictionary *userInfo);
void DEVICE_InitNotifBadge();
extern const struct _stMyModuleInfo gstMyModuleInfo70;


@implementation WDAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
InitAppLaunchOptions(launchOptions);
InitInstance();
InitInternalLanguage(12);
InitModule(&gstMyModuleInfo1);
InitModule(&gstMyModuleInfo3);
InitModule(&gstMyModuleInfo4);
InitModule(&gstMyModuleInfo6);
InitModule(&gstMyModuleInfo7);
InitModule(&gstMyModuleInfo8);
InitModule(&gstMyModuleInfo9);
InitModule(&gstMyModuleInfo10);
InitModule(&gstMyModuleInfo21);
InitModule(&gstMyModuleInfo28);
InitModule(&gstMyModuleInfo37);
InitModule(&gstMyModuleInfo42);
InitModule(&gstMyModuleInfo61);
InitModule(&gstMyModuleInfo68);
InitModule(&gstMyModuleInfo69);
DEVICE_InitNotifBadge();
InitModule(&gstMyModuleInfo70);
InitExec();
LoadWDLFile(@"Contact Me Pro");

CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ];
window = [ [ UIWindow alloc ] initWithFrame: screenBounds ];
#ifdef __IPHONE_7_0
OBJ_InitIOS(window, YES);
#else
OBJ_InitIOS(window, NO);
#endif //__IPHONE_7_0
[window makeKeyAndVisible];

// Ajout prise en charge patche pour ios 10, 9 et 8, ios 7 en natinf windev 20
[self registerForRemoteNotifications];

return YES;
}

// ici traitement pour ios 10
- (void)registerForRemoteNotifications {
if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")){
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
// envois erreur ˆ windev
DEVICE_HandlePushNotificationRegistrationError(error);
}
}];
}
// ici traitement pour ios 8 et 9
else if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"9.0") || SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"8.0")){

// ici traitement pour activation notifification 8 et 9
}
else {
// Code for old versions Version ios 7 dŽja pris en charge par windev 20 en natif
}
}

//Called when a notification is delivered to a foreground app. // reception ios 10
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
// Affiche directement la notification meme si windev au premier plan
// completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
// et ou donne la main a windev
DEVICE_HandlePushNotification(notification.request.content.userInfo);
}

//Called to let your app know which action was selected by the user for a given notification. // reception ios 10
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
// Affiche directement la notification
// completionHandler();
// donne la main a windev
DEVICE_HandlePushNotification(response.notification.request.content.userInfo);
}

- (void)applicationWillResignActive:(UIApplication *)application {
OBJ_SendApplicationWillResignActive();
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
ExecDidEnterBackground();
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
ExecWillEnterForeground();
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
OBJ_SendApplicationDidBecomeActive();
}


- (void)applicationWillTerminate:(UIApplication *)application {
TermExec();
}

////////////////////////////////////////////////////////////////////////////////////////
//////////////// Gestion des notification Natif Windev 20. //////////////////////////
//////////////// ˆ garder pour compatibilitŽ !! //////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
DEVICE_HandleNotification(notification);
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
{
DEVICE_HandlePushNotificationRegistration(devToken);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
DEVICE_HandlePushNotificationRegistrationError(err);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
DEVICE_HandlePushNotification(userInfo);
}
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// FIN ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}


- (void)dealloc {
[window release];
[super dealloc];
}


@end


Et voila il ne vous reste à compilé sous xcode et whaouu les notifications Phush fonction
Message modifié, 21 juin 2017 - 19:59