Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Notification not working in ios. — Gideros Forum

Notification not working in ios.

SarthakSarthak Member
edited March 2015 in General questions
I have used notification plugins by following all the steps, but in Xcode5 it's working in simulator, but in Xcode6.1 it is not working as well as in device too.

Please help me, my code is...
 
               local note = Notification.new(1)
		note:setTitle("Chook Run")
		note:setMessage("Don't forget to share Chook Run with your friends, click here to post on facebook.")
		note:setSound("Sfx/popUp.mp3")
		note:dispatchAfter({sec = 1}, {min = 2})
 
	       local mngr = NotificationManager.getSharedInstance()
	        mngr:addEventListener(Event.LOCAL_NOTIFICATION, function(e)
		print("Local notification: "..e.id)
		print("Title: "..e.title)
		print("Text: "..e.message)
		print("Number: "..e.number)
		print("Sound: "..e.sound)
	   --	text:setText("Id: "..e.id)
 
	    --AlertDialog.new("test", "Reminder"..e.id, "Ok"):show()

Comments

  • SarthakSarthak Member
    edited March 2015
    Below code is working in android,but in ios its not working from secondtime onwards.

    When i install in ios device firsttime, it asks about pushnotification as well as local notification also working by changing date, but after that i delete that app, and install same build in device,it is not asking for pushnotification as well as local notification is also not working. So please guide me.
     
    		--id of notification to modify
    		local id = 1
     
    		--retrieve shared instance
    		local mngr = NotificationManager.getSharedInstance()
     
    		--retrieve table with scheduled notifications
    		local t = mngr:getScheduledNotifications()
     
    		--check if id is in it
    		if t[id] then
    			AlertDialog.new("chok run...!!"," if."..id,"OK"):show()
    		else
    			AlertDialog.new("Congrats...!!"," else."..id,"OK"):show()
    			--notification is still scheduled
    			--let's modify it by creating new instance with same id
    			local note = Notification.new(id)
    			note:setTitle("Chook Run")
    			note:setMessage("Don't forget to share  with your friends, click here to post on facebook.")
    			note:setSound("Sfx/popUp.mp3")
    			--if we want to modify dispatch time we need to redispatch it
    			note:dispatchAfter({day = 30}, {day=30})
    		end
     
     
    		mngr:addEventListener(Event.LOCAL_NOTIFICATION, function(e)
    			print("Local notification: "..e.id)
    			print("Title: "..e.title)
    			print("Text: "..e.message)
    			print("Number: "..e.number)
    			print("Sound: "..e.sound)
    		--	text:setText("Id: "..e.id)
    		end)
  • tkhnomantkhnoman Member
    Accepted Answer
    This is what i remembered.
    When it already installed once, it won't ask to allow notification anymore.
    It would appear at Settings > Notifications when your app is in your device.
    If it doesn't appear, try to add this on didFinish:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // None of the code should even be compiled unless the Base SDK is iOS 8.0 or later
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
        // The following line must only run under iOS 8. This runtime check prevents
        // it from running if it doesn't exist (such as running under iOS 7 or earlier).
        if ([application respondsToSelector:<a href="http://forum.giderosmobile.com/profile/selector%28registerUserNotificationSettings" rel="nofollow">@selector(registerUserNotificationSettings</a><img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/smile.png" title=":)" alt=":)" height="20" />]) {
            [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
        }
    #endif
    }
    I used it recently, Xcode 6, and it still works.
  • SarthakSarthak Member
    edited March 2015
    Thank you buddy, it works.

    Gideros code is perfect, just i need to modify xcode code, so below is my Appdelegate code,which works

    (below code should be in didFinish)
     #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
            // The following line must only run under iOS 8. This runtime check prevents
            // it from running if it doesn't exist (such as running under iOS 7 or earlier).
            if ([application respondsToSelector:<a href="http://forum.giderosmobile.com/profile/selector%28registerUserNotificationSettings" rel="nofollow">@selector(registerUserNotificationSettings</a><img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/smile.png" title=":)" alt=":)" height="20" />]) {
                [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound  categories:nil]];
            }
        #endif
     
     
     
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0){
     
        }else{
            UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
            UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
     
        }
     
        self.launchLocalNotification =
        [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
        self.launchRemoteNotification =
        [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

    :)
Sign In or Register to comment.